Subscribe ( )

iPhone Programming Tutorials


 

Forum

You must be logged in to post Login Register

Search 

more than 1 view

User Post

2:43 am
October 8, 2008


thathoo

Noob

posts 1

1

hi brandon,

first – awesome job with the site!

i am trying to create an app with more than 1 view and have a situation where in with 1 button tap on view1 – the user should be able to fade into view2..sorta like the example viewtransition on apple.com – but i need objects like buttons and stuff on each view which are going to be different in each view…

so i created 2 view controllers and in the appdelegate file inside applicationDidFinishLaunching i have:

    MyViewController *aViewController = [[MyViewController alloc]
                                         initWithNibName:@”ControllerView” bundle:[NSBundle mainBundle]];
    self.myViewController = aViewController;
    [aViewController release];
   
    SecondViewController *yaViewController = [[SecondViewController alloc]
                                              initWithNibName:@”YaView” bundle:[NSBundle mainBundle]];
    self.mySecondViewController = yaViewController;
    [yaViewController release];
   
    // setup the view
    UIView *controllersView = [myViewController view];
    [window addSubview:controllersView];
   
    UIView *var = [mySecondViewController view];
    [window addSubview:var];

   [window makeKeyAndVisible];

but of course this gives me errors – what do u think is the way i should go about this…

2:43 pm
October 8, 2008


VertigoSol

Moderator

posts 26

2

Yoiur best way to do things in a heirarchy structure such as
UIWindow
|
View
| |
subview subview
You can only have one view on the screen at a time but you can add subviews to that view. You would want to do something like this

MyViewController *aViewController = [[MyViewController alloc]
initWithNibName:@”ControllerView” bundle:[NSBundle mainBundle]];
self.myViewController = aViewController;
[aViewController release];

SecondViewController *yaViewController = [[SecondViewController alloc]

initWithNibName:@”YaView” bundle:[NSBundle mainBundle]];
self.mySecondViewController = yaViewController;
[yaViewController release];

// make a view the whole screen wide
UIView *mainView = [[UIView alloc] initWithFrame[[UIScreen mainScreen] bounds]

//add both the view to the main view
[mainView addSubview:aViewController.view];
[mainView addSubview:yaViewController.view]

//add the view to the window
[window addSubview:mainView];

This may not be syntactically correct but the concept is

e^i -1 =0

Search 

About the iCodeBlog forum

Most Users Ever Online:

44


Currently Online:

6 Guests

Forum Stats:

Groups: 2

Forums: 6

Topics: 419

Posts: 893

Membership:

There are 934 Members

There has been 1 Guest

There are 2 Admins

There is 1 Moderator

Top Posters:

bobcubsfan – 54

crazyiez – 30

Uhu – 17

AdeC – 17

Nick – 15

jitesh61 – 12

Administrators: Brandon (88 Posts), Collin (0 Posts)

Moderators: VertigoSol (26 Posts)



©   

  • Posted by on 6 Aug 2008 in Uncategorized
  •   |  
  •   |  
  •   |  
  • Comments Off

Comments are closed.