兼容适配比较简单,只需要在prenset之前加一个系统校验:
if (UI_USER_INTERFACE_IDIOM()== UIUserInterfaceIdiomPad) {
if (alertController.popoverPresentationController != nil) {
alertController.popoverPresentationController.sourceView = self.view;
alertController.popoverPresentationController.sourceRect = CGRectMake(touchPoint.x, touchPoint.y, 1.0, 1.0);
}
}
[self presentViewController:alertController animated:YES completion:nil];