我在导航项中有一个 UIBarButtonItem
,它显示一个 UIActionSheet
,其中包含一个用于切换快速设置的按钮:
操作表由按钮项显示:
[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/