我在滚动视图中有三个视图。我通过以下代码添加了它们;
[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知道当前转换已完成“
非常感谢任何帮助。
答案 0 :(得分:0)
您无法呈现当前的导航控制器。而是展示您的MyVC
viewcontroller
MyVC *vc = [[MyVC alloc] initWithNibName:@"VC" bundle:nil];
vc.modalPresentationStyle = UIModalPresentationFormSheet;
vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self
presentModalViewController:vc animated:YES];
[vc release];
您还可以创建一个新的视图控制器层次结构,将它们推送到新的导航控制器并显示它。
答案 1 :(得分:0)
您不应该尝试从内部呈现视图控制器的导航控制器。而是为模态视图控制器创建一个新的导航控制器:
MyVC *vc = [[MyVC alloc] initWithNibName:@"VC" bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:vc];
navigationController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:navigationController animated:YES];
[vc release];