当我使用exc_bad_access
dismissviewcontrolleranimated
presentViewController
代码为:
TestViewController *testViewController=[[TestViewController alloc] init];
UINavigationController *nav=[[UINavigationController alloc] initWithRootViewController:testViewController];
[self presentViewController:nav animated:YES completion:^{
NSLog(@"presentViewController is finish");
}];
但是,当我删除UINavigationController
时,错误就会消失。
TestViewController *testViewController=[[TestViewController alloc] init];
[self presentViewController:testViewController animated:YES completion:^{
NSLog(@"presentViewController is finish");
}];
感谢您的帮助。
答案 0 :(得分:0)
UINavigationController
有推送和拉动转换,您正尝试将Modal Transition
应用于它。
答案 1 :(得分:0)
现在的视图控制器通过“根视图控制器”呈现,而不是UINavigationController。 您应该像这样
从Parent VC或Base VC中展示您的VCTestViewController *testViewController=[self.storyboard instantiateViewControllerWithIdentifier:@"storyboardIDofViewController"];//set the storyboard ID of the TestViewController in your storyboard by selecting attribute inspector after selecting the view controller.
[self presentViewController:testViewController animated:YES completion:^{
NSLog(@"presentViewController is finish");
}];
这是从另一个VC呈现VC的正确方法。