开发者

Push more than 1 UIViewController at once

开发者 https://www.devze.com 2023-01-22 23:40 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消