gestureRecognizer
UITapGestureRecognizer* singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
[self.view addGestureRecognizer:singleTap]; //这个可以加到任何控件上,比如你只想响应WebView,我正好填满整个屏幕
singleTap.delegate = self;
singleTap.cancelsTouchesInView = NO;
[singleTap release];
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}
如果没有将自己赋值给UITapGestureRecognizer的委托,那么gestureRecognizer就不会被执行
作者:GangWang
出处:http://www.cnblogs.com/GnagWang/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。