iOS Multiview App
I am trying to build a multiview app i.e. based on some gestures, new views are shown, removed etc.
I have found 3 ways to do so -
[self.view insertSubview:newViewController.view atIndex:3];
- Using
UINavigationC开发者_开发百科ontroller
- Finally using modalViewController -
[self presentModalViewController:newViewController animated:YES];
First off, in second method, can I use this controller without UINavigationTabBar
? I have a set of custom UIView
objects which I want to push & pop from Screen. I dont want the ugly Apple's NavigationBar at top (or bottom). I will provide custom buttons based on which [self.navigationController popViewControllerAnimated]
should occur. Can this be possible?
Also, Which of these techniques is best? In terms of usage & code maintenance, memory usage etc.
In terms of usage & code maintenance, memory usage etc., there's little doubt that UINavigationController
is the best fit. It's been optimized for exactly the sort of thing you're doing. And because you push and pop UIViewController
s from it (not just UIView
s), views that are not currently displayed on screen can be automatically released to free up memory by the OS.
Can you use a navigation view without the bar across the top? I think maybe you should RTFM. Specifically, -setNavigationBarHidden:animated:
That said, UINavigationController
is not particularly flexible at doing things it wasn't designed to do. In particular, it's opinionated about the transitions it uses to animate between view controllers on its stack.
You might have some luck pushing and popping sans animation (by passing NO
to the animated:
parameter of those methods), and having a delegate set up to handle -navigationController:willShowViewController:animated:
. You could in theory add a CATransition
to the root view's animations there. But anything much more complicated than that (a view that tracks your finger while sliding on to the screen, etc.) and you'll probably have to write your own controller and manage your own views.
But you should still read Apple's View Controller Programming Guide for iOS and the NSNavigationManager
specs until you grok them in their fullness. It'd be hard to find a better pattern to base your design around.
Second one UINavigationController. And yes you can use your custom navigation bar.
精彩评论