嘿,我想能够检查用户是否触摸我的UIView所以我可以解雇我的选择器我怎么能这样做呢?谢谢!
答案 0 :(得分:10)
尝试在包含UITapGestureRecognizer
的{{1}}子类的UIView
中的viewDidLoad
课程中添加UIViewController
。它看起来像这样:
UIView
然后实现tap的处理程序,根据上面的代码,它将如下所示:
- (void)viewDidLoad {
[super viewDidLoad];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewTapped:)];
tap.numberOfTapsRequired = 1;
[self.aView addGestureRecognizer:tap];
[tap release];
}
希望这有帮助,
贾斯汀