我只想知道如何识别用户何时在模式对话框之外点击。我已经尝试过了,但是当用户在外面点击时它没有被调用。
这是我的 viewDidLoad 方法,它位于 ModalDialogViewController.m 文件 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];
}
这不是打开 handleTapBehind 方法。
我已将模态视图控制器设为 UIGestureRecognition 的协议。