dismissModalViewControllerAnimated crashing on iOS6

白昼怎懂夜的黑 提交于 2019-12-11 16:50:02

问题


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];


回答1:


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

vc.modalPresentationStyle = UIModalPresentationCurrentContext;




回答2:


maybe because dismissModalViewController is deprecated in iOS6? Try

[self dismissViewControllerAnimated:YES completion:nil];



回答3:


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]; }];



来源:https://stackoverflow.com/questions/12628294/dismissmodalviewcontrolleranimated-crashing-on-ios6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!