iOS开发UI高级手势识别器
####手势识别器
UIGestureRecognizer类
·UITapGestureRecognizer(轻击)
·UIPinchGestureRecognizer(捏合)
·UIPanGestureRecognizer(平移) 事实调用
·UISwipeGestureRecognizer(轻扫)
·UIRotationGestureRecognizer(旋转)
·UILongPressGestureRecognizer(长按)
alloc initwithTar
[singleTap requireGestureRecognizerToFail:doubleTap];
####具体实现
//1 单击
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction:)];
[imageV addGestureRecognizer:tap];
//2 双击
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction1:)];
//点击的次数
doubleTap.numberOfTapsRequired = 2;
[imageV addGestureRecognizer:doubleTap];
//双击失败是单击 ---->双击成功,单击不算
[tap requireGestureRecognizerToFail:doubleTap];
//3 长按
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longPressAction:)];
[imageV addGestureRecognizer:longPress];
//4 轻扫
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeAction:)];
//属性:轻扫方向
swipe.direction = UISwipeGestureRecognizerDirectionRight;
[imageV addGestureRecognizer:swipe];
//5 移动 实时调用
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(panAction:)];
[imageV addGestureRecognizer:pan];
//轻扫失败算移动--->轻扫成功 移动失败
[pan requireGestureRecognizerToFail:swipe];
//6 旋转
UIRotationGestureRecognizer *rotation = [[UIRotationGestureRecognizer alloc]initWithTarget:self action:@selector(totationAction:)];
[imageV addGestureRecognizer:rotation];
//7 捏合
UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(pinchAction:)];
[imageV addGestureRecognizer:pinch];