问题
在iphone中可以正常使用UIActivityViewController,UIAlertController,但在ipad上就会报错
原因
从报错中可以看出,在ipad上弹出信息框需要挂靠在某个视图上。
解决方法
在UIActivityViewController,UIAlertController下添加以下代码
//activityVC就是你要弹出的UIActivityViewController
let popover = activityVC.popoverPresentationController
//从该View中弹出UIActivityViewController
popover?.sourceView = self.view
popover?.sourceRect = CGRect(x: 0, y:Int(UIScreen.main.bounds.size.height), width: Int(UIScreen.main.bounds.size.width), height: 30)
popover?.permittedArrowDirections = UIPopoverArrowDirection.any