push view controller after dismissing presented view controller

蹲街弑〆低调 提交于 2019-12-04 23:14:34

Error has been in other. If Im right understand: some animations before dismissing presented view controller are blocking animations in navigation stack. I solved this problem with 2 ways:

1) deleteting or set right animations before dismissing

2) use setViewControllers in navigation controller (I select it)

- (void)dismissAndPush:(UIViewController *)vc {
    [self dismissViewControllerAnimated:NO completion:^{
        NSMutableArray *mutableControllers = [NSMutableArray arrayWithArray:self.navigationController.viewControllers];
        NSArray *controllers = [mutableControllers arrayByAddingObject:vc];
        [self.navigationController setViewControllers:controllers animated:NO];
    }];

}

From Apple Documentation:

The presenting view controller is responsible for dismissing the view controller it presented.

So, VC1 should be dismissing the ModalVC, try to do this

ModalVC on click:

   if ([self.delegate respondsToSelector:@selector(dismissAndPush:)]) {
       [self.delegate performSelector:@selector(dismissAndPush:) withObject:VC2];
   }

In VC1:

- (void)dismissAndPush:(UIViewController *)vc {

[self dismissViewControllerAnimated:YES completion:^{
    [self.navigationController pushViewController:vc animated:NO];
}];

}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!