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

kwjohns

macrumors 6502a
Original poster
Jul 4, 2007
700
12
I have a root view that has some icons on it that when pressed will take you into a navigation controller. However, I need to add more icons than what will fit on the view, therefore I would like to separate some of the icons within different segments with a segmented control. So I'm wanting to load a different view (xib) when a different segment is selected. I'm not having any luck finding any examples that explain how to push another root view, though. All I can find is how to push a view deeper into a navigation controller.

Hope this makes sense.

Edit: Here's an example of what I mean.

example.png


I have the segmented control code setup, I just don't know what to put within:

Code:
UISegmentedControl* segCtl = sender;
	if( [segCtl selectedSegmentIndex] == 0 ){
		
	}
	
	if( [segCtl selectedSegmentIndex] == 1 ) {
		
	}

to load the different xib.
 

B U G E Y E

macrumors newbie
Apr 2, 2009
4
0
Portland, OR
If all you're going to need are the two views, you could just create them both, and use the segmented control to toggle the "hidden" property on each. Actually, just toggling the foremost one might be enough.

If you want to use a navigation controller, you can use one view as the root view, and the other as a pushed view. I did this in one of my apps. Just pass NO for the "animated" parameter and the view will just appear. Something like this:

Code:
if ( [segCtl selectedSegmentIndex] == 0 ) {

    [navController popToRootViewControllerAnimated:NO];
		
} else if ( [segCtl selectedSegmentIndex] == 1 ) {

    [navController pushViewController:someViewController animated:NO];
		
}

Hope that helps...
 

kwjohns

macrumors 6502a
Original poster
Jul 4, 2007
700
12
If all you're going to need are the two views, you could just create them both, and use the segmented control to toggle the "hidden" property on each. Actually, just toggling the foremost one might be enough.

Ah that will work! For some reason I was thinking different view = different xib file. Not the case! Thanks!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.