【发布时间】:2015-06-10 19:52:32
【问题描述】:
我正在尝试从UIBarButtonItem 显示UIAlertController,就像在Facebook 应用程序的网络浏览器中单击操作按钮时一样。但一直没有成功。一直在 Stack Overflow、Google、Github 等上搜索,但没有找到我要找的东西。
您可以在此处查看 Facebook 应用程序中的外观:UIAlertController in the Facebook app
下面是我尝试过的代码,但我注意到popoverPresentationController 属性是nil。
func showActionSheet(sender: AnyObject) {
var optionsAlert = UIAlertController(title: nil, message: nil, preferredStyle: .ActionSheet)
// Add the actions
optionsAlert.modalPresentationStyle = .Popover
optionsAlert.popoverPresentationController?.barButtonItem = sender as! UIBarButtonItem
presentViewController(optionsAlert, animated: true, completion: nil)
}
如果有人能帮我解决这个问题,我将不胜感激。
提前致谢!
【问题讨论】:
-
真的吗?你确定吗?它不应该是零。不是我运行上面的代码。
-
是的,我确定。我不知道我尝试了多少方法让它发挥作用。我尝试将 modalInPopover 设置为 true,但它仍然不起作用。我在网上搜索过,但我只找到未回答的问题。请帮忙
标签: ios iphone uibarbuttonitem uialertcontroller