我正试图从 UIBarButtonItem
显示一个 UIAlertController
,就像点击动作按钮时Facebook应用程序中的Web浏览器一样 . 但是找到了我正在寻找的东西 .
在这里你可以看到它在Facebook应用程序中的样子:UIAlertController in the Facebook app
下面是代码I 've tried, but I' ve注意到 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)
}
如果有人能帮助我,我将非常感激 .
提前致谢!
1 回答
我得出的结论是,不可能将UIAlertController显示为iPhone上的popover . 这不是我最初想到的在Facebook应用程序中所做的,理由是你无法在UIAlertAction中添加图标 .
我设法通过在我的故事板中添加一个UITableViewController并添加一个popover segue来解决它 . 以下教程帮助了我:http://richardallen.me/2014/11/28/popovers.html