views:

144

answers:

1

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?

Thanks,

Mike

+1  A: 

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

FirstViewController.m
#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

SecondViewController *secondVC = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
//set any properties
[self.navigationController pushViewController:secondVC animated:YES];
[secondVC release];
DVG
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
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 http://developer.apple.com/iphone/library/documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html
DVG