Search code examples
iphoneiosuiactionsheettouch-event

Can I pull up a UIActionSheet with a touchable background?


I have a UIPickerView on a UIActionSheet. Right now the UIActionSheet makes the view behind the UIActionSheet not touchable. Is there a way that I can make it touchable? Or is that just how a UIActionSheet works?


Solution

  • I don't believe it is possible to make the view behind the UIActionSheet touchable without dismissing it first. They're meant to be modal, i.e. require the user's attention before being dismissed.

    From UIActionSheet class reference (emphasis mine):

    For applications running on iPhone and iPod touch devices, the action sheet typically slides up from the bottom of the window that owns the view. For applications running on iPad devices, the action sheet is typically displayed in a popover that is anchored to the starting view in an appropriate way. Taps outside of the popover automatically dismiss the action sheet, as do taps within any custom buttons. You can also dismiss it programmatically.

    I suppose a way around this could be that you just create your own view that displays similarly. For example, create a UIView that you can animate the same (slide up) when a button is pressed. This UIView can contain your UIPickerView and whatever else you need (probably a cancel button to dismiss it).

    Hope this helps, good luck!