ios - ActionSheet 源 View BarButtonItem

标签 ios swift uibarbuttonitem uialertcontroller uipopover

我在导航栏中有一个栏按钮项,当按下它时,将显示一个 UIAlertController,其样式为 .ActionSheet。在 iPhone 中,它以我想要的方式出现。对于 iPad 我知道我需要添加

// For iPad, set the pop over bounds
var popOver = optionMenu.popoverPresentationController
popOver?.sourceView = button as UIView
popOver?.sourceRect = (button as UIView).bounds
popOver?.permittedArrowDirections = UIPopoverArrowDirection.Any

有谁知道将条形按钮项用作 sourceViewsourceRect 的方法吗?我希望弹出框指向栏按钮项。

最佳答案

只需使用popOver?.barButtonItem = myBarButtonItem

关于ios - ActionSheet 源 View BarButtonItem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29949374/

相关文章:

objective-c - 如何使用AFNetwork下载多个文件

ios - 在 iOS 上检测主页按钮按下?

swift - 创建 NSManagedObject 类的新实例

ios - 将具体实例传递给需要协议(protocol)参数的闭包

ios - 如何为某些用户隐藏栏按钮项目

ios - 在 UIToolbar 中更改 UIBarButtonItem 上的 tintColor 会导致按钮消失并从左侧开始动画

ios - 可编辑 UITableView 的内存错误(iOS 7 ARC)

ios - 安全运送名称

ios - Firebase - 无法将类型 'AppDelegate' 的值分配给类型 'UNUserNotificationCenterDelegate?'

iPhone SDK : UIBarButtonItem not refreshing after Memory warning