尝试从弹出窗口显示UIActionSheet时,是否有人收到此消息?
Your application has presented a UIAlertController () of style UIAlertControllerStyleActionSheet. The modalPresentationStyle of a UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this popover through the alert controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem. If this information is not known when you present the alert controller, you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.
在GM之前,我使用了一些解决方法将UIActionSheet转换为UIAlertController,这很好用 . 然而,似乎Apple试图解决UIActionSheet问题,我不想使用我的解决方法 - 但似乎我别无选择......
5 回答
要支持iPad,请包含以下代码:
如果您在用户对
UITableView
中的单元格进行选择后显示操作表 . 我发现这个效果很好:您需要提供
popoverPresentationController
for iPad支持 . 在此,您可以指定barButtonItem
或sourceView
. 这个另一个主题可以帮到你:Swift UIAlertController - ActionSheet iPad iOS8 Crashes实际上,对于iPhone和iPad设计来说,这是Xcode中的一些错误(我相信) .
在iPhone中,相同的代码工作正常,您可以在同一位置(始终)看到警报消息 . 但对于iPad,您需要定义警报框的位置
alert.popoverPresentationController.sourceView = self.view; alert.popoverPresentationController.sourceRect = CGRectMake(self.view.bounds.size.width / 2.0 - 105, self.view.bounds.size.height / 2.0 + 70, 1.0, 1.0);
105和70是由于不同的锚点,iPad纵向设计的近似尺寸差异 .在iPhone设计
UIAlertController
附带'Modal View'但不幸的是,如果你使用相同的代码为iPad,它将不是'Modal View' . 这意味着您需要编写额外的代码来禁用iPad设计中的触摸 . 我认为这很奇怪 .在iPad设计中,您需要考虑锚点是不同的 . 它是气泡三角形点,而不是AlertView的左上角 .
这些是我看到的奇怪的事情 . 我认为必须有一个标准,如果有人想要出标准,那么可以有其他选择 .
UIAlertController只是iOS8,需要支持iOS7,我正在使用它 . 我在iPad上的主/细节布局中的主视图上遇到了这个问题 . 通过使用[actionSheet showInView:]从父UISplitViewController引发UIActionSheet,我能够解决它(不完全修复它) . 祝好运 .