Question

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.

Was it helpful?

Solution

Is this intended behavior?

Yes.

From the documentation of 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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top