【发布时间】:2014-11-10 10:11:51
【问题描述】:
我正在创建并展示一个ActionSheet,如下所示:
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .ActionSheet)
alertController.modalPresentationStyle = .Popover
// Add some buttons
alertController.popoverPresentationController?.delegate = self
alertController.popoverPresentationController?.barButtonItem = someBarButton
self.presentViewController(alertController, animated: true, completion: nil)
这在 iPad 上运行良好,但在 iPhone 上 alertController.popoverPresentationController 是 nil。
我已经成功地在 iPhone 上使用自适应 segue 样式 Present As Popover 在界面生成器中呈现弹出框,并实现 adaptivePresentationStyleForPresentationController 委托方法以返回正确的 UIModalPresentationStyle 但我不知道如何在代码中使用UIAlertController 执行此操作,因为它在 iPhone 上没有 popoverPresentationController
【问题讨论】:
-
不是您要找的答案,我可能对此有误,但我认为即使在 iOS 8 中,也无法在 iPhone 的弹出窗口中显示操作表。跨度>
-
这个链接可以帮到你:) stackoverflow.com/a/25656733/3964913
-
@GordonWorswick 很遗憾没有。根据我的问题,
UIAlertController在 iPhone 上没有popoverPresentationController -
下面的链接可能有用;useyourloaf.com/blog/2014/09/05/…
-
popover 在 Iphone 中是不可能的,这是只为 Ipad 实现的功能,如果你仍然想要一个 popover 尝试使用自定义弹出屏幕。
标签: ios iphone popover uialertcontroller