3

I have a UIBarButtonItem in a navigation item that displays a UIActionSheet with a button to toggle a quick setting:

UIActionSheet screenshot

The action sheet is presented from the button item:

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

However, here's the problem I'm encountering:

When I tap below the navigation bar, for example anywhere in the calendar, the UIActionSheet dismisses, which is expected. Any touch outside the sheet, in my opinion, should dismiss it.

But: I can still tap on the "Settings" and "Done" buttons in the navigation bar, and not only is the action sheet not dismissed, but the buttons function.

So, tapping "Settings" while the UIActionSheet is open, causes another to be opened. This can easily be avoided by checking to see if the action sheet is already open.

But, the "Done" button dismisses the entire calendar view, leaving the UIActionSheet hovering over the view that originally presented the calendar.

Is this intended behavior? While I could disable the buttons when the action sheet is presented, and enable them when it's dismissed, this seems like an unnecessary workaround.

4

1 回答 1

2

这是预期的行为吗?

是的。

从文档showFromBarButtonItem:animated:

在 iPad 上,此方法在弹出窗口中显示操作表,并将拥有该按钮的工具栏添加到弹出窗口的传递视图列表中。因此,工具栏中的点击会导致相应工具栏项的操作方法被调用。如果您希望在点击不同的工具栏项时关闭弹出框,则必须在您的操作处理程序方法中实现该行为。

于 2013-10-23T14:53:46.190 回答