iOS-为试图添加手势
2016-03-12 08:27
531 查看
初始化手势同时添加手势事件---把手势添加到视图上 // 1.轻拍手势类 // 创建一个轻拍手势 同时绑定了一个事件 UITapGestureRecognizer *aTapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGRAction:)]; // 设置轻拍次数 aTapGR.numberOfTapsRequired = 1; // 设置手指触摸的个数 aTapGR.numberOfTouchesRequired = 2; // 添加手势 [self.rootView addGestureRecognizer:aTapGR]; [aTapGR release]; // 2.长按手势 UILongPressGestureRecognizer *longPressGR = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressAction:)]; [self.rootView addGestureRecognizer:longPressGR]; [longPressGR release]; // 3.旋转手势 UIRotationGestureRecognizer *rotationGR = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotationAction:)]; [self.rootView.testImageView addGestureRecognizer:rotationGR]; [rotationGR release]; // 4.捏合手势 UIPinchGestureRecognizer *pinchRG = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchAction:)]; [self.rootView addGestureRecognizer:pinchRG]; [pinchRG release]; // 5.平移手势 UIPanGestureRecognizer *panGR = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGRAction:)]; [self.rootView.testImageView addGestureRecognizer:panGR]; [panGR release]; // 6.轻扫手势 UISwipeGestureRecognizer *swipeGR = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGRAction:)]; // 设置滑动方向 默认是从左往右 swipeGR.direction = UISwipeGestureRecognizerDirectionLeft; // 设置向左滑动 [self.rootView.testImageView addGestureRecognizer:swipeGR]; [swipeGR release]; // 7.屏幕边缘轻扫识别器 UIScreenEdgePanGestureRecognizer *screenPGR = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(screenEdgeGRAction:)]; [self.rootView addGestureRecognizer:screenPGR]; [screenPGR release];
相关文章推荐
- iPhone之横竖屏与自动旋转
- [PHP]利用XAMPP搭建本地服务器, 然后利用iOS客户端上传数据到本地服务器中(四. iOS端代码实现)
- [PHP]利用XAMPP搭建本地服务器, 然后利用iOS客户端上传数据到本地服务器中(三. PHP端代码实现)
- IOS开发指南摘记
- iOS 开发中的LaunchScreen
- iOS内功篇:runtime
- iOS开发常识
- IOS逆向【2】-cydia之开发者模式
- 使用Xcode7的Instruments检测解决iOS内存泄露
- ios全局返回按钮和全屏侧滑功能
- 关于iOS自定义控件:在view上实现事件和代理
- Xcode开发的常见问题与解决方案
- iOS模拟器,点击textfield为什么不弹出软键盘
- IOS中根视图控制器的剖析
- iOS中使用的tableview为group形式时如何设置不同sections的间距
- iOS 开源项目介绍之动画篇
- IOS 如何隐藏tabbar
- XZ_iOS中清除缓存的实现
- iOS_Block界面传值
- iOS学习之路——博客资源