step1
.h文件中声明实现<UIGestureRecognizerDelegate>
step2
.m文件中
// 单击的 Recognizer
UITapGestureRecognizer* singleRecognizer;
singleRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:selfaction:@selector(SingleTap:)];
//点击的次数
singleTapRecognizer.numberOfTapsRequired = 1; // 单击
//给self.view添加一个手势监测;
[self.view addGestureRecognizer:singleRecognizer];
实现协议
-(void)SingleTap:(UITapGestureRecognizer*)recognizer
{ //处理单击操作
}
时间: 2024-10-11 07:21:38