1.手势操作,单击双击的区分
记得在作为delegate的view的头文件加上<UIGestureRecognizerDelegate>
tapRecognizer.maximumNumberOfTouches = 1;//设定次数
[A requireGestureRecognizerToFail:B]函数,它可以指定当A手势发生时,即便A已经滿足条件了,也不会立刻触发,会等到指定的手势B确定失败之后才触发。
第二种方式:
-(void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event{
UITouch*touch=[touches anyObject];
if(touch.tapCount==1){
[UIViewanimateWithDuration:0.3animations:^{
UIImage*image=[UIImageimageNamed:@"view1.png"];
imageView.image=image;
[self.view addSubview:imageView];
}completion:nil];}
elseif(touch.tapCount==2){
[UIViewanimateWithDuration:0.3animations:^{
UIImage*image=[UIImageimageNamed:@"view2.png"];
imageView.image=image;
[self.view addSubview:imageView];
}completion:nil];}
}