UIViewController presentViewController crashing on

2019-07-24 19:31发布

问题:

Just got this error in our error logging system, been searching hi and low and can't seem to find any solution. Any help is appreciated. Here is the stacktrace.

回答1:

May be in your XCODE log you might have encountered this message

"Presenting view controllers on detached view controllers is discouraged ".

If yes then then try

[self.view.window.rootViewController presentViewController:myVC];

if this fails then make sure you call presentViewController:myVC on immediate presenting ViewController i.e. in your case what I see from trace - CalendarEventDetailViewController.

If that too fail then go backward - from where you are invoking VC which in turn use presentViewController, in iOS8 presentation layer has changed specially WRT UIAlert/UIActionSheet, and UIPopovers, if you are using any of these, create UIAlertController as a separate code track for iOS8 and use presentViewController:myVC on presenting ViewController.

I was facing similar issue where presentViewController: not working at all or disrupting presenting VC contents, in some situations dismissViewController was crashing. Using this approach I could fix it.



标签: ios8 uikit