Modal View Controller crash
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 control开发者_运维技巧ler 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.
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.
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];
精彩评论