定义响应的手势类:长按手势,缩放手势
来源:互联网 发布:淘宝海外购物要身份证 编辑:程序博客网 时间:2024/04/29 14:57
定义响应的手势类:长按手势,缩放手势
// 初始化数据-(id) initWithData:(LQCityData *)citydata{// always call "super" init// Apple recommends to re-assign "self" with the "super's" return valueif( (self=[super init]) ) { //定义响应的手势类(支持所有UI手势) //长按手势 UILongPressGestureRecognizer * longPressRecognizer = [[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanFrom:)] autorelease]; longPressRecognizer.minimumPressDuration = 0.5f; longPressRecognizer.allowableMovement = 1.0f; longPressRecognizer.cancelsTouchesInView = false; [[[CCDirector sharedDirector] view] addGestureRecognizer:longPressRecognizer]; //缩放手势 UIPinchGestureRecognizer *gestureRecognizer = [[[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinchFrom:)] autorelease]; [[[CCDirector sharedDirector] view] addGestureRecognizer:gestureRecognizer]; // Enable touch [self setIsTouchEnabled:YES]; } return self;}
//手势识别函数- (void)handlePanFrom:(UIGestureRecognizer *)recognizer { //CCLOG(@"handlePanFrom %s %@",__FUNCTION__, recognizer); if ([recognizer isKindOfClass:[UILongPressGestureRecognizer class]]) { CCLOG(@"UILongPressGestureRecognizer"); //长按手势 [self selectedOneBuilding:(LQCityBuilding*)clickSprite_]; } if ([recognizer isKindOfClass:[UIPinchGestureRecognizer class]]){ if([recognizer state] == UIGestureRecognizerStateBegan) lastScale_ = self.scale; //1 UIPinchGestureRecognizer *recog = (UIPinchGestureRecognizer*)recognizer; float nowScale = (lastScale_ - 1) + recog.scale; //2 nowScale = MIN(nowScale,2);//设置缩放上限 //3 nowScale = MAX(nowScale,0.8);//设置缩放下限 //4 //-1.得到移动允许的范围 //-2.添加缩小时的处理 self.scale = nowScale;//5 }}
- 定义响应的手势类:长按手势,缩放手势
- 长按手势响应弹出UIActionSheet碰到的问题
- 手势缩放
- 手势:长按
- 长按手势实现
- iOS 长按手势
- iOS 长按手势
- UILongPressGestureRecognizer长按手势
- 长按手势
- 轻扫手势/平移、长按手势
- iOS手势识别使用(拖动,缩放,旋转,点击,长按,滑动,自定义手势)等等
- 手势
- 手势
- 手势
- 手势
- 手势
- 手势
- 手势
- UIImageView默认的UserInteractionEnabled是NO
- Android系统文件夹结构解析(六)--/system/media & /system/sounds & /system/usr etc.
- Get process's navigation path by using process name
- win7 建立FTP服务器的方法
- Android应用程序签名详解
- 定义响应的手势类:长按手势,缩放手势
- 兼容xilinx公司开发板设计--基于FMC接口的DSP TMS320C6455子卡模块
- linux 与库相关的一些命令
- VB 小结(一)
- 王爽《汇编语言》第10章 检测点10.5(1)的疑问
- java操作oracle数据库
- Circular linked list and Josephus ring
- css代码格式化清理工具
- 求 2/1+3/2+5/3+8/5+13/8.....前20项之和?