模态视图控制器崩溃

发布于 2024-12-06 06:24:21 字数 669 浏览 0 评论 0原文

我在滚动视图中有三个视图。我通过以下代码添加了它们;

[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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

绿萝 2024-12-13 06:24:21

您无法显示当前的导航控制器。显示您的 MyVC 视图控制器

MyVC *vc = [[MyVC alloc] initWithNibName:@"VC" bundle:nil];
vc.modalPresentationStyle = UIModalPresentationFormSheet;
vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self
presentModalViewController:vc animated:YES]; 
[vc release];

您还可以创建新的视图控制器层次结构,将它们推送到新的导航控制器并显示它。

You cann't present current navigation controller. Present instead your MyVC viewcontroller

MyVC *vc = [[MyVC alloc] initWithNibName:@"VC" bundle:nil];
vc.modalPresentationStyle = UIModalPresentationFormSheet;
vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self
presentModalViewController:vc animated:YES]; 
[vc release];

You can also create a new hierarchy of view controllers, push them to a new navigation controller and present it.

自由如风 2024-12-13 06:24:21

您不应该尝试从自身内部呈现视图控制器的导航控制器。相反,为您的模态视图控制器创建一个新的导航控制器:

MyVC *vc = [[MyVC alloc] initWithNibName:@"VC" bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:vc];
navigationController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

[self presentModalViewController:navigationController animated:YES];
[vc release];

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:

MyVC *vc = [[MyVC alloc] initWithNibName:@"VC" bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:vc];
navigationController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

[self presentModalViewController:navigationController animated:YES];
[vc release];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文