currently i\'m running into big trouble with my ActionSheet. On iPhone it works great, but on iPad it only crashes
I create a new project with only one button
<
If you want show your alert in center and no arrow, I tryed this, it works on iOS 11.2
swift 4.2 version:
let actionSheet = UIAlertController ......
if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.pad ){
if let currentPopoverpresentioncontroller = actionSheet.popoverPresentationController{
currentPopoverpresentioncontroller.permittedArrowDirections = []
currentPopoverpresentioncontroller.sourceRect = CGRect(x: (self.view.bounds.midX), y: (self.view.bounds.midY), width: 0, height: 0)
currentPopoverpresentioncontroller.sourceView = self.view
self.present(actionSheet, animated: true, completion: nil)
}
}else{
self.present(actionSheet, animated: true, completion: nil)
}
Objective C version:
UIAlertController* actionSheet
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
NSArray *empty;
UIPopoverPresentationController *currentPopOverPresentationController = [actionSheet popoverPresentationController];
currentPopOverPresentationController.permittedArrowDirections = empty;
currentPopOverPresentationController.sourceRect = CGRectMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds), 0, 0);
currentPopOverPresentationController.sourceView = self.view;
[self presentViewController:actionSheet animated:YES completion:nil];
}else{
[self presentViewController:actionSheet animated:YES completion:nil];
}