Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

tommyh1122

macrumors newbie
Original poster
May 19, 2008
8
0
I am hoping someone can help me. I am new to iPhone development and have a problem that is probably pretty simple.

If you have a .xib file with two views how do you specify a view to load? From the main screen I have two buttons one is to call one view the other to call the other view from the .xib file. When I make the call it is loading the view that is connected with the Files's Owner view.

Code:
- (IBAction)switchLFamilies:(id)sender
{
	SecondSwapeViewController *familiesL = [[SecondSwapeViewController alloc] initWithNibName:nil bundle:nil];
	familiesL.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
	[self presentModalViewController:familiesL animated:YES];

}

Any help would be appreciated...Thank you..
 

Attachments

  • Screen shot 2010-05-20 at 9.35.34 PM.png
    Screen shot 2010-05-20 at 9.35.34 PM.png
    36.7 KB · Views: 73

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
When your view controller is presented it obviously shows the view that is set as its view property. If you want to show another view then you need to have an outlet for the other view and then set the view controller's self.view to the other view.
 

tommyh1122

macrumors newbie
Original poster
May 19, 2008
8
0
I do have an outlet for each of the view's (portrait, landscape) but this not being called from the SecondSwapeViewController.m, it is being called from SwapeViewController.m.
 

Attachments

  • Screen shot 2010-05-21 at 5.42.13 AM.png
    Screen shot 2010-05-21 at 5.42.13 AM.png
    17.6 KB · Views: 498

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
Add a method to your view controller that has two views. This method will save a BOOL that tells it which view should be shown and set self.view = whateverView. Also add code that sets the correct view based on this BOOL in the view controller's viewDidLoad. After you alloc/init the view controller call this method.


Code:
	SecondSwapeViewController *familiesL = [[SecondSwapeViewController alloc] initWithNibName:nil bundle:nil];
	familiesL.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
        [familiesL showView2:YES];
	[self presentModalViewController:familiesL animated:YES];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.