UIAlertController handle dismiss upon click outside (IPad)
- by Tomer Peled
Previous to iOS8 we used the UIActionSheet for showing alert and now we need to use the UIAlertController.
When we used the UIActionSheet we could easily handle situations where the user clicked outside the pop up (which means he want to cancel the operation) by comparing the clickedButtonAtIndex to the cancelButtonIndex - if the user indeed pressed outside the popup we got the cancel button index in this function.
How can we handle these situations with the new UIAlertController? I tried to use the "completion" block but it doesn't have any context. Is there an easy way to handle this? (other than "saving" the actions states in some general variable).