【发布时间】:2020-07-22 05:57:05
【问题描述】:
我的应用程序将 UIAlertController 用于 ActionSheet 和 Alert。它在 iPad 中的 iOS 13.4 上运行良好,但如果我从我的 iOS 13.6 设备运行代码,则在 iPad 12.9 ios 13.6 中无法正常运行。
let alert = UIAlertController(title: "Select Image", message: nil, preferredStyle:
UIAlertController.Style.actionSheet)
alert.addAction(UIAlertAction(title: "Camera", style: UIAlertAction.Style.default,
handler: { (res) in
self.btnClickedCamera(tag:2)
}))
alert.addAction(UIAlertAction(title: "Gallery", style: UIAlertAction.Style.default,
handler: { (res) in
self.btnClickedGallery(tag:2)
}))
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { (res) in
}))
if let popoverPresentationController = alert.popoverPresentationController {
popoverPresentationController.sourceView = sender
popoverPresentationController.sourceRect = sender.bounds
}
self.present(alert, animated: true, completion: nil)
【问题讨论】:
-
" popoverPresentationController.sourceView = sender" 在这一行中,什么是“sender”?是“发件人”是 UIButton
-
@Ashutosh kumar Mishra 先生,是的,它的 UIButton
-
Hey Pawan,我已经在模拟器中运行了你的代码(设备:- iPhone 11 Pro 13.6),它工作正常。
-
@Ashutosh kumar Mishra 先生,它也不能在 Ipad 12.9(第 4 代)ios 13.6 上运行
-
嗨 Pawan,现在我在 iPad pro(12.9- 第 4 代)上使用了你的代码。再次它正常工作。
标签: ios swift iphone alert uialertcontroller