UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"title" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *action = [UIAlertAction actionWithTitle:@"Title" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}
[alertController addAction:action];
alertController.popoverPresentationController.sourceView = self.view;
alertController.popoverPresentationController.sourceRect = CGRectMake(100,100,100.0,100.0);
[self presentViewController:alertController animated:YES completion:nil];
其中
alertController.popoverPresentationController.sourceView
alertController.popoverPresentationController.sourceRect
如果iPad上不加這兩句代碼的話沃测,會(huì)導(dǎo)致程序崩潰的。iPhone上是沒有這樣的問題。這個(gè)需要注意一下