All I want to know is how to I recognise when a user taps outside of the modal dialog. I have tried this but it is not being called when the user taps outside.
Here is my viewDidLoad method which resides in the ModalDialogViewController.m file UITapGestureRecognizer *recognizer;
if(![self.view.window.gestureRecognizers containsObject:recognizer])
{
recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapBehind:)];
//[recognizer setDelegate:self];
[recognizer setNumberOfTapsRequired:1];
recognizer.cancelsTouchesInView = NO; //So the user can still interact with controls in the modal view
[self.view.window addGestureRecognizer:recognizer];
}
This is not opening the handleTapBehind method.
I have made the modal view controller a protocol of UIGestureRecognition.