首页 > 代码库 > UIView上的滑动手势及动作
UIView上的滑动手势及动作
- ///////////注flowView为UIView//////////
- //添加滑动手势事件
- UIPanGestureRecognizer *gestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:flowView action:@selector(handleGesture:)];
- [flowView addGestureRecognizer:gestureRecognizer];
- //添加点击手势事件
- flowView.userInteractionEnabled = YES;
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:flowView action:@selector(goBigImageView)];
- [flowView addGestureRecognizer:tap];
- //滑动手势(里面有手势的不同状态,根据需要进行灵活运用)
- - (void)handleGesture:(UIPanGestureRecognizer *)recognizer {
- //UITapGestureRecognizer
- if (recognizer.state == UIGestureRecognizerStateChanged){
- NSLog(@"UIGestureRecognizerStateChanged");
- }else if(recognizer.state == UIGestureRecognizerStateEnded){
- NSLog(@"UIGestureRecognizerStateEnded");
- }else if(recognizer.state == UIGestureRecognizerStateBegan){
- NSLog(@"UIGestureRecognizerStateBegan");
- }else if(recognizer.state == UIGestureRecognizerStateCancelled){
- NSLog(@"UIGestureRecognizerStateCancelled");
- }else if(recognizer.state == UIGestureRecognizerStateFailed){
- NSLog(@"UIGestureRecognizerStateFailed");
- }else if(recognizer.state == UIGestureRecognizerStatePossible){
- NSLog(@"UIGestureRecognizerStatePossible");
- }else if(recognizer.state == UIGestureRecognizerStateRecognized){
- NSLog(@"UIGestureRecognizerStateRecognized");
- }
- }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。