码迷,mamicode.com
首页 > 移动开发 > 详细

iOS开发UI高级手势识别器

时间:2016-05-17 11:23:09      阅读:260      评论:0      收藏:0      [点我收藏+]

标签:

####手势识别器
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];

iOS开发UI高级手势识别器

标签:

原文地址:http://www.cnblogs.com/VIPZC/p/5500481.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!