Push more than 1 UIViewController at once
H开发者_运维百科ow do i push more than 1 UIViewController at once?
I've found the best way to do this is to use the setViewControllers:animated: method. For example, here's a method which you can use to have a view controller push an array of view controllers:
- (void)pushViewControllers:(NSArray *)vcs animated:(BOOL)animated
{
NSMutableArray *vcArray = [NSMutableArray arrayWithArray:self.navigationController.viewControllers];
[vcArray addObjectsFromArray:vcs];
[self.navigationController setViewControllers:vcArray animated:animated];
}
The last object in the array vcs
will animate on to the screen, but the other view controllers in the array will precede it on the view controller stack.
You can call [self.navigationController pushViewController: foo animated: NO]
multiple times to build up a stack of controllers.
you can push views in - (void)viewDidAppear:(BOOL)animated method in every view controller.
精彩评论