ios - UIActionSheet不阻止外部触摸, "under"

标签 ios ipad ios7 uiactionsheet

我在导航项中有一个 UIBarButtonItem,它显示一个 UIActionSheet,其中包含一个用于切换快速设置的按钮:

UIActionSheet screenshot

操作表由按钮项显示:

[calendarSettingsSheet showFromBarButtonItem:self.navigationItem.leftBarButtonItem animated:YES];

但是,这是我遇到的问题:

当我点击导航栏下方(例如日历中的任意位置)时,UIActionSheet 将关闭,这是预期的。在我看来,任何在工作表之外的触摸都应该将其忽略。

但是:我仍然可以点击导航栏中的“设置”和“完成”按钮,不仅操作表不会消失,而且按钮也起作用 em>.

因此,在 UIActionSheet 打开时点击“设置”会导致打开另一个 UIActionSheet。通过检查操作表是否已打开,可以轻松避免这种情况。

但是,“完成”按钮会关闭整个日历 View ,使 UIActionSheet 悬停在最初显示日历的 View 上。

这是预期的行为吗?虽然我可以在显示操作表时禁用按钮,并在操作表关闭时启用它们,但这似乎是一个不必要的解决方法。

最佳答案

Is this intended behavior?

是的。

来自 showFromBarButtonItem:animated: 的文档

On iPad, this method presents the action sheet in a popover and adds the toolbar that owns the button to the popover’s list of passthrough views. Thus, taps in the toolbar result in the action methods of the corresponding toolbar items being called. If you want the popover to be dismissed when a different toolbar item is tapped, you must implement that behavior in your action handler methods.

关于ios - UIActionSheet不阻止外部触摸, "under",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19545000/

相关文章:

ios - 我有一个没有背景的 png 文件,如何在 iOS 中为该图像创建清晰的彩色背景?

ios - Swift CoreData 编辑/更新实体,当它只有 1 个实例时

ipad - 自动续订订阅发生未知错误

ios - 在 iOS7 中安装二进制文件时的奇怪行为

iphone - 未找到 Storyboard文件 'MainStoryboard_iPad~ipad.storyboardc'

ios - 切换到菜单栏中的 View Controller

ios - 如何构建仍然兼容存档并上传到 AppStore 的 Framework fat 二进制文件(所有 archs)?

iphone - 取消缩放 UIScrollView

ios - Appium检查器未加载

具有后台多任务处理且无 APNS 的 iOS7 文本聊天应用程序