App crashing in UIPopoverPresentationController but no explicit popovers?
Not sure if it's the same cause as the original question, but I have the exact same error and the issue was using a UIAlertController with an ActionSheet style, presenting it worked fine on iPhone but iPad requires a sourceview to be set - https://stackoverflow.com/a/24233937/285694
This is a just similar situation. I had a crash bug on [UIPopoverPresentationController presentationTransitionWillBegin]
on iOS 9+, and turns out that the crash occurred when sourceView
was nil
.
Example (in Objective-C):
UIViewController *vc = <#instance#>.vc.modalPresentationStyle = UIModalPresentationPopover;vc.popoverPresentationController.delegate = self;vc.popoverPresentationController.sourceView = sourceView; // <--- this MUST NOT be nil.vc.popoverPresentationController.sourceRect = sourceView.bounds;[self presentViewController:vc animated:YES completion:nil];
It most probable the ActionSheet
crash in iPad.
You should have a if condition like:
if let popoverController = alertVC.popoverPresentationController { popoverController.sourceView = self.view popoverController.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0) popoverController.permittedArrowDirections = [] }