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.

Gabriele Petronella
  • 106,943
  • 21
  • 217
  • 235
Craig Otis
  • 31,257
  • 32
  • 136
  • 234
  • I believe it's the same issue as http://stackoverflow.com/questions/6136792/uipopovercontroller-does-not-dismiss-when-clicking-on-the-navigationbar, I think they use UIPopoverViewController under-the-hood for this. Unfortunately, we do not have access to that and you might need to dismiss it manually. – tia Oct 23 '13 at 14:54

1 Answers1

2

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.

Gabriele Petronella
  • 106,943
  • 21
  • 217
  • 235
  • 1
    It appears that in iOS 7.1.1, the photos App has this same problem. 1) In a "moments" view, tap "Select" 2) Tap your photo 3) Tap the trash can icon to delete photo, but don't delete 4) Now tap "Add To". Notice how the "Add To" controller is presented and the "Delete Photo" popover/actionsheet is still visible. You can also do this with the trash can and "Share" button. – Ngoan Nguyen Aug 21 '14 at 01:04