XCode 4 (iPhone) Navigation in sub views
I'm in the process of creating an application for the iPhone for a client of ours and I'm stuck. Basically the application has a homepage (so to speak) which is simply a grid of (custom) buttons that when pressed takes you through to a specific part of the application. The home page is fairly plain with no navigation or tab bars displaying. However the majority of the other areas require navigation that will start at the point the area is first entered for instance I click from the home page into an area and from there I could click further into the app and at any point I can use the navigation controller to get all the way back to the first page of that area. I've written a couple of test apps that use navigation and seen many examples while trying to figure this out but they all have the Navigation Controller implemented in the App Delegate and then display it in the Main Window but I don't want it to be displayed in the first view. Firstly, is what I'm trying to do possible? (I suspect it is because most things are). And secondly what is the preferred wa开发者_如何学Cy of achieving it? Any help would be much appreciated.
you can use a Navigation Controller even for the root level, then show/hide the navigation bar as necessary when you push or pop items on the navigation stack.
You should look into the -setNavigationBarHidden:animated:
method on UINavigationController, which you could call in -viewWillAppearAppear:
and -viewWillDisappear
or in the navigation controller's delegate.
If your "Home Page" is just a UIViewController, you can present a UINavigationController modally which will allow you to navigate through to different areas. From your "Home Page" I would call the following:
NextViewController *nextView= [[[NextViewController alloc] initWithNibName:nil bundle:nil] autorelease];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:modalViewController];
[self presentModalViewController:navigationController animated:YES];
精彩评论