iOS 手势识别 ——长按和轻扫(swipe)
2015-08-15 11:42
519 查看
#import "MJViewController.h" @interface MJViewController () @property (weak, nonatomic) IBOutlet UIView *redView; @end @implementation MJViewController - (void)viewDidLoad { [super viewDidLoad]; UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeView)]; swipe.direction = UISwipeGestureRecognizerDirectionUp; [self.redView addGestureRecognizer:swipe]; } - (void)swipeView { NSLog(@"swipeView"); } - (void)testLongPress { UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] init]; [longPress addTarget:self action:@selector(longPressView)]; // 至少长按2秒 longPress.minimumPressDuration = 2; // 在触发手势之前,50px范围内长按有效 longPress.allowableMovement = 50; [self.redView addGestureRecognizer:longPress]; } - (void)longPressView { NSLog(@"长按了红色的view"); } @end
相关文章推荐
- 解决 iOS8 定位授权的问题
- iOS 手势识别 旋转和缩放(捏合)
- Ios 从无到有项目 MVVM模式(两)
- 自定义iOS7导航栏背景,标题和返回按钮文字颜色
- IOS第十天(1:QQ好友列表 ,自定义的headview,代理 ,通知 ,black的使用)
- IOS第九天(3:QQ聊天界面通知的使用)
- IOS第九天(2:QQ聊天界面键盘优化 和自动回复)
- webrtc 编译完成,安装时错误
- IOS第九天(1:QQ聊天界面frame模型)
- webrtc 编译汇编文件时错误
- IOS7 适配以及向下兼容问题
- iOS 手势识别——敲击 Tap
- ios基金会-XCode温馨提示
- iOS概念入门学习-OC-类和对象
- iOS 代理与block 逆向传值 学习
- iOS 代理为啥要用weak修饰? (刨根问底一)
- iOS 万能跳转界面方法(runtime实用篇一)
- iOS 9之Shared Links Extension(Safari Extensibility)
- iOS 浅赋值、深复制、完全复制的知识点梳理验证(附加归档解档)
- 【iOS】随机三角瓷砖布局算法