Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIActionSheet Dismiss when click/ tap outside

I'm novice in iPhone development. Can anyone tell me how to dismiss UIActionSheet control when i tapped outside of it?

In my actionSheet i have only datePicker control and it pops up over tab bar control now what i want whenever user click outside of it, it should dismiss instead of using actionSheet's cancel button. Regards

like image 737
RizWiz Avatar asked Sep 13 '11 13:09

RizWiz


1 Answers

An even more simpler solution would be to just add a Cancel button. This will automatically enable tap-background-to-dismiss: (Swift)

alertController.addAction(UIAlertAction(title: "Cancel",
                                        style: .cancel,
                                        handler: nil))
like image 161
Bouke Avatar answered Oct 07 '22 21:10

Bouke