Take the 2-minute tour ×

I am trying to build an fairly simple iPad app that requires me to navigate through multiple views. What I want to do is have some sort of main menu view with multiple buttons on it, and when you click one of the buttons the new view appears and then you work with that. I'm new to iPad development, so I have a few questions about the best way to get this done.

1) If I build the views in Interface Builder, how do I make them aware of each other in Xcode? I can't seem to figure out what I need to do in order to code a button to say "Open View 'Foo'"

2) When I open the views, how should I be adding them in relation to the main menu view? Should I add the new view as a subview of the main menu view, or should I close the main menu view, open the new view, and then reopen the main menu upon closing the first view? I imagine both ways are possible, but are there any performance implications I should be aware of?



share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

I'm making an assumption that it's more or less the same between iPhone and iPad. I haven't started iPad development yet.

You make view controllers aware of each other by importing their headers in your implementation files

#import "SecondViewController.h"

If you're going for a navigation-style app, you should embed your top level view controller in a navigation controller, then you advance to the next one by calling

//set any properties
[self.navigationController pushViewController:secondVC animated:YES];
[secondVC release];
share|improve this answer
I'm not exactly doing a navigation-style app, although one of my views will need something like that so you've inspired me to start implementing it in the subview. It will basically be a slide show that you can navigate through using the controller. My question about that would be, is it possible to load all the views and the order of the views in the navigationController? I would like to easily be able to modify the order and views of any views managed by the controller without having to update each view with the new flow. Does that make sense? –  Mike C Aug 9 '10 at 20:59
UINavigationController has an array of View Controllers that you can set like a property, so it still sounds like the way you want to go. If it's static content, like it sounds, just collect the view controllers in an array then assign it to the navigation controller and push and pop like normal. See developer.apple.com/iphone/library/documentation/uikit/… –  DVG Aug 10 '10 at 14:13
add comment

Your Answer


