模态视图控制器崩溃
我在滚动视图中有三个视图。我通过以下代码添加了它们;
[self.scrollView addSubview:[aViewController view]];
当我滚动视图时,我想呈现一个带有自己的导航控制器的模式视图控制器,但这会导致崩溃。这是我用来显示模态视图的代码
MyVC *vc = [[MyVC alloc] initWithNibName:@"VC" bundle:nil];
self.navController.modalTransitionStyle=UIModalTransitionStyleCrossDissolve;
self.navController.viewControllers = [NSArray arrayWithObject:vc];
[vc release];
[self presentModalViewController:self.navController animated:YES];
,我得到的崩溃是:由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“尝试开始从 到 的模态转换,而转换已经在进行中” 。等待 viewDidAppear/viewDidDisappear 知道当前转换已完成'
任何帮助将不胜感激。
I have three views inside a scroll view. I've added them via the following code;
[self.scrollView addSubview:[aViewController view]];
When I scroll the view I want to present a modal view controller with its own navigation controller, however this causes a crash. Here's the code I'm using to show the modal view
MyVC *vc = [[MyVC alloc] initWithNibName:@"VC" bundle:nil];
self.navController.modalTransitionStyle=UIModalTransitionStyleCrossDissolve;
self.navController.viewControllers = [NSArray arrayWithObject:vc];
[vc release];
[self presentModalViewController:self.navController animated:YES];
And the crash I get is:erminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempting to begin a modal transition from to while a transition is already in progress. Wait for viewDidAppear/viewDidDisappear to know the current transition has completed'
Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法显示当前的导航控制器。显示您的
MyVC
视图控制器您还可以创建新的视图控制器层次结构,将它们推送到新的导航控制器并显示它。
You cann't present current navigation controller. Present instead your
MyVC
viewcontrollerYou can also create a new hierarchy of view controllers, push them to a new navigation controller and present it.
您不应该尝试从自身内部呈现视图控制器的导航控制器。相反,为您的模态视图控制器创建一个新的导航控制器:
You should not be trying to present a view controller's navigation controller from within itself. Instead, create a new navigation controller for your modal view controller: