Abhinav
Abhinav

Reputation: 38162

dismissModalViewControllerAnimated crashing on iOS6

I am facing a crash on iOS 6.0. I have a view controller from which I present a navigation view controller modally and then from the navigation stack I present another view controller modally and finally to dismiss the whole modal stack I pass the following message to my first view controller from where I showed the navigation controller.

Now this works fine on iOS below 6.0. How should I handle this?

[self dismissModalViewControllerAnimated:YES];

Upvotes: 0

Views: 3155

Answers (3)

Ronen Morecki
Ronen Morecki

Reputation: 434

I had this similar crash as well and one of the things helped me solve it was adding:

vc.modalPresentationStyle = UIModalPresentationCurrentContext;

Upvotes: 4

David Hoerl
David Hoerl

Reputation: 41642

EDIT: Lets say you add a method to appDelegate called 'makeMeNumberOne:(UIViewController *)vc': (I know you use the 'modal' versions, they are deprecated in iOS6, switch to 'presented' variants) . Also I assume you can find the navigationController, if this is a problem add a comment I'll further expand this, and assume you are using ARC.)

  • the parameter you have is a strong reference, it holds the current presented viewController, lets call it pvc

  • ask the navigationController for its viewControllers, and get the last one

  • as a debugging tool, verify that this vc has a non-nil presentedViewController property

  • message the last view controller above:

    [lastOne dismissViewControllerAnimated:NO completion:^{ [navigationController.viewControllers = @[pvc]; }];

Upvotes: 3

user1078170
user1078170

Reputation:

maybe because dismissModalViewController is deprecated in iOS6? Try

[self dismissViewControllerAnimated:YES completion:nil];

Upvotes: 3

Related Questions