UIGestureRecognizer介绍

【手势识别-UIPinchGestureRecognizer捏合-UIPanGestureRecognizer缩放 Objective-C语言】 阅读详情

1、UIGestureRecognizer介绍
手势识别在iOS上非常重要,手势操作移动设备的重要特征,极大的增加了移动设备使用便捷性。

 

iOS系统在3.2以后,为方便开发这使用一些常用的手势,提供了UIGestureRecognizer类。手势识别UIGestureRecognizer类是个抽象类,下面的子类是具体的手势,开发这可以直接使用这些手势识别。

 

UITapGestureRecognizer  
UIPinchGestureRecognizer
UIRotationGestureRecognizer
UISwipeGestureRecognizer
UIPanGestureRecognizer
UILongPressGestureRecognizer

 

上面的手势对应的操作是: 
Tap(点一下)
Pinch(二指往內或往外拨动,平时经常用到的缩放)
Rotation(旋转)
Swipe(滑动,快速移动)
Pan (拖移,慢速移动)
 LongPress(长按)
UIGestureRecognizer的继承关系如下:
 

2、使用手势的步骤
使用手势很简单,分为两步:


1)创建手势实例。当创建手势时,指定一个回调方法,当手势开始,改变、或结束时,回调方法被调用。
2)添加到需要识别的View中。每个手势只对应一个View,当屏幕触摸在View的边界内时,如果手势和预定的一样,那就会回调方法。

ps:一个手势只能对应一个View,但是一个View可以有多个手势。建议在真机上运行这些手势,模拟器操作不太方便,可能导致你认为手势失效。

 

3、Pan 拖动手势:
1.UIImageView *snakeImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"snake.png"]];  
2.snakeImageView.frame = CGRectMake(50, 50, 100, 160);  
3.UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc]  
4.                                                initWithTarget:self  
5.                                                action:@selector(handlePan:)];      
6.[snakeImageView addGestureRecognizer:panGestureRecognizer];  
7.[self.view setBackgroundColor:[UIColor whiteColor]];  
8.[self.view addSubview:snakeImageView]; 


新建一个ImageView,然后添加手势
回调方法:
1.- (void) handlePan:(UIPanGestureRecognizer*) recognizer  
2.{  
3.    CGPoint translation = [recognizer translationInView:self.view];  
4.    recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x,  
5.                                   recognizer.view.center.y + translation.y);  
6.    [recognizer setTranslation:CGPointZero inView:self.view];  
7.      
8.} 

 

4、Pinch缩放手势
1.UIPinchGestureRecognizer *pinchGestureRecognizer = [[UIPinchGestureRecognizer alloc]  
2.                                                        initWithTarget:self  
3.                                                        action:@selector(handlePinch:)];

[snakeImageView addGestureRecognizer:pinchGestureRecognizer];


1.- (void) handlePinch:(UIPinchGestureRecognizer*) recognizer  
2.{  
3.    recognizer.view.transform = CGAffineTransformScale(recognizer.view.transform, recognizer.scale, recognizer.scale);  
4.    recognizer.scale = 1;  
5.}    


5、Rotation旋转手势
1.UIRotationGestureRecognizer *rotateRecognizer = [[UIRotationGestureRecognizer alloc]  
2.                                                 initWithTarget:self  
3.                                                 action:@selector(handleRotate:)];  
4.[snakeImageView addGestureRecognizer:rotateRecognizer]; 


1.- (void) handleRotate:(UIRotationGestureRecognizer*) recognizer  
2.{  
3.    recognizer.view.transform = CGAffineTransformRotate(recognizer.view.transform, recognizer.rotation);  
4.    recognizer.rotation = 0;  
5.} 


 

添加了这几个手势后,运行看效果,程序中的imageView放了一个这样的图片
                    /^\/^\
                  _|__|  O|
         \/     /~     \_/ \
          \____|__________/  \
                 \_______      \
                         `\     \                 \
                           |     |                  \
                          /      /                    \
                         /     /                       \\
                       /      /                         \ \
                      /     /                            \  \
                    /     /             _----_            \   \
                   /     /           _-~      ~-_         |   |
                  (      (        _-~    _--_    ~-_     _/   |
                   \      ~-____-~    _-~    ~-_    ~-_-~    /
                     ~-_           _-~          ~-_       _-~   
                        ~--______-~                ~-___-~
在模拟器上拖动是没问题的。缩放和旋转有点问题,估计是因为在模拟器上的模拟的两个接触点距离在imageView的边界外了,所以操作无效果。建议在真机上运行这个手势。

 

在模拟器上缩放和选择的操作技巧:可以把imageView的frame值设置大一点,按住alt键,按下触摸板(不按下不行),这样就可以旋转和缩放了。


6、添加第二个ImagView并添加手势
记住:一个手势只能添加到一个View,两个View当然要有两个手势的实例了。

- (void)viewDidLoad  
{  
    [super viewDidLoad];  
  
    UIImageView *snakeImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"snake.png"]];  
    UIImageView *dragonImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"dragon.png"]];  
    snakeImageView.frame = CGRectMake(120, 120, 100, 160);  
    dragonImageView.frame = CGRectMake(50, 50, 100, 160);  
    [self.view addSubview:snakeImageView];  
    [self.view addSubview:dragonImageView];  
      
    for (UIView *view in self.view.subviews) {  
        UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc]  
                                                        initWithTarget:self  
                                                        action:@selector(handlePan:)];  
          
        UIPinchGestureRecognizer *pinchGestureRecognizer = [[UIPinchGestureRecognizer alloc]  
                                                            initWithTarget:self  
                                                            action:@selector(handlePinch:)];  
          
        UIRotationGestureRecognizer *rotateRecognizer = [[UIRotationGestureRecognizer alloc]  
                                                         initWithTarget:self  
                                                         action:@selector(handleRotate:)];  
          
        [view addGestureRecognizer:panGestureRecognizer];  
        [view addGestureRecognizer:pinchGestureRecognizer];  
        [view addGestureRecognizer:rotateRecognizer];  
        [view setUserInteractionEnabled:YES];  
    }  
    [self.view setBackgroundColor:[UIColor whiteColor]];       
} 


多添加了一条龙的view,两个view都能接收上面的三种手势。运行效果如下:

7、拖动(pan手势)速度(以较快的速度拖放后view有滑行的效果)

如何实现呢?
1)监视手势是否结束
2)监视触摸的速度

- (void) handlePan:(UIPanGestureRecognizer*) recognizer  
{  
    CGPoint translation = [recognizer translationInView:self.view];  
    recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x,  
                                       recognizer.view.center.y + translation.y);  
    [recognizer setTranslation:CGPointZero inView:self.view];  
      
    if (recognizer.state == UIGestureRecognizerStateEnded) {  
          
        CGPoint velocity = [recognizer velocityInView:self.view];  
        CGFloat magnitude = sqrtf((velocity.x * velocity.x) + (velocity.y * velocity.y));  
        CGFloat slideMult = magnitude / 200;  
        NSLog(@"magnitude: %f, slideMult: %f", magnitude, slideMult);  
          
        float slideFactor = 0.1 * slideMult; // Increase for more of a slide   
        CGPoint finalPoint = CGPointMake(recognizer.view.center.x + (velocity.x * slideFactor),  
                                         recognizer.view.center.y + (velocity.y * slideFactor));  
        finalPoint.x = MIN(MAX(finalPoint.x, 0), self.view.bounds.size.width);  
        finalPoint.y = MIN(MAX(finalPoint.y, 0), self.view.bounds.size.height);  
          
        [UIView animateWithDuration:slideFactor*2 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{  
            recognizer.view.center = finalPoint;  
        } completion:nil];  
          
    }  
    

代码实现解析:
1)计算速度向量的长度(估计大部分都忘了)这些知识了。
2)如果速度向量小于200,那就会得到一个小于的小数,那么滑行会很短
3)基于速度和速度因素计算一个终点
4)确保终点不会跑出父View的边界
5)使用UIView动画使view滑动到终点


运行后,快速拖动图像view放开会看到view还会在原来的方向滑行一段路。


8、同时触发两个view的手势
手势之间是互斥的,如果你想同时触发蛇和龙的view,那么需要实现协议
UIGestureRecognizerDelegate,
@interface ViewController : UIViewController  
@end 

 

并在协议这个方法里返回YES。
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer  
{  
    return YES;  
} 


把self作为代理设置给手势:
panGestureRecognizer.delegate = self;  
pinchGestureRecognizer.delegate = self;  
rotateRecognizer.delegate = self; 

这样可以同时拖动或旋转缩放两个view了。

 

9、tap点击手势
这里为了方便看到tap的效果,当点击一下屏幕时,播放一个声音。为了播放声音,我们加入AVFoundation.framework这个框架。
- (AVAudioPlayer *)loadWav:(NSString *)filename {  
    NSURL * url = [[NSBundle mainBundle] URLForResource:filename withExtension:@"wav"];  
    NSError * error;  
    AVAudioPlayer * player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];  
    if (!player) {  
        NSLog(@"Error loading %@: %@", url, error.localizedDescription);  
    } else {  
        [player prepareToPlay];  
    }  
    return player;  
} 


我会在最后例子代码给出完整代码,添加手势的步骤和前面一样的。

1.#import    
2.#import    
3.  
4.@interface ViewController : UIViewController  
5.@property (strong) AVAudioPlayer * chompPlayer;  
6.@property (strong) AVAudioPlayer * hehePlayer;  
7.  
8.@end 

 

运行,点一下某个图,就会播放一个咬东西的声音。不过这个点击播放声音有点缺陷,就是在慢慢拖动的时候也会播放。这使得两个手势重合了。怎么解决呢?使用手势的:requireGestureRecognizerToFail方法。

 

10、手势的依赖性

在viewDidLoad的循环里添加这段代码:
[tapRecognizer requireGestureRecognizerToFail:panGestureRecognizer]; 

 

意思就是,当如果pan手势失败,就是没发生拖动,才会出发tap手势。这样如果你有轻微的拖动,那就是pan手势发生了。tap的声音就不会发出来了。


11、自定义手势
自定义手势继承:UIGestureRecognizer,实现下面的方法:
– touchesBegan:withEvent:
– touchesMoved:withEvent:
– touchesEnded:withEvent:
- touchesCancelled:withEvent:

 

新建一个类,继承UIGestureRecognizer,代码如下:

.h文件

#import 
typedef enum {
    DirectionUnknown = 0,
    DirectionLeft,
    DirectionRight
} Direction;

@interface HappyGestureRecognizer : UIGestureRecognizer
@property (assign) int tickleCount;
@property (assign) CGPoint curTickleStart;
@property (assign) Direction lastDirection;

@end

 

.m文件

#import "HappyGestureRecognizer.h"   
#import    
#define REQUIRED_TICKLES        2   
#define MOVE_AMT_PER_TICKLE     25   
  
@implementation HappyGestureRecognizer  
  
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {  
    UITouch * touch = [touches anyObject];  
    self.curTickleStart = [touch locationInView:self.view];  
}  
  
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {  
      
    // Make sure we've moved a minimum amount since curTickleStart   
    UITouch * touch = [touches anyObject];  
    CGPoint ticklePoint = [touch locationInView:self.view];  
    CGFloat moveAmt = ticklePoint.x - self.curTickleStart.x;  
    Direction curDirection;  
    if (moveAmt < 0) {  
        curDirection = DirectionLeft;  
    } else {  
        curDirection = DirectionRight;  
    }  
    if (ABS(moveAmt) < MOVE_AMT_PER_TICKLE) return;  
      
    // 确认方向改变了   
    if (self.lastDirection == DirectionUnknown ||  
        (self.lastDirection == DirectionLeft && curDirection == DirectionRight) ||  
        (self.lastDirection == DirectionRight && curDirection == DirectionLeft)) {  
          
        // 挠痒次数   
        self.tickleCount++;  
        self.curTickleStart = ticklePoint;  
        self.lastDirection = curDirection;  
          
        // 一旦挠痒次数超过指定数,设置手势为结束状态   
        // 这样回调函数会被调用。   
        if (self.state == UIGestureRecognizerStatePossible && self.tickleCount > REQUIRED_TICKLES) {  
            [self setState:UIGestureRecognizerStateEnded];  
        }  
    }  
      
}  
  
- (void)reset {  
    self.tickleCount = 0;  
    self.curTickleStart = CGPointZero;  
    self.lastDirection = DirectionUnknown;  
    if (self.state == UIGestureRecognizerStatePossible) {  
        [self setState:UIGestureRecognizerStateFailed];  
    }  
}  
  
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event  
{  
    [self reset];  
}  
  
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event  
{  
    [self reset];  
}  
  
@end 


调用自定义手势和上面一样,回到这样写:
- (void)handleHappy:(HappyGestureRecognizer *)recognizer{
    [self.hehePlayer play];
}

手势成功后播放呵呵笑的声音。在真机上运行,按住某个view,快速左右拖动,就会发出笑的声音了。


代码解析:
先获取起始坐标:curTickleStart
通过和ticklePoint的x值对比,得出当前的放下是向左还是向右。再算出移动的x的值是否比MOVE_AMT_PER_TICKLE距离大,如果太则返回。
再判断是否有三次是不同方向的动作,如果是则手势结束,回调。

参考:http://www.raywenderlich.com/6567/uigesturerecognizer-tutorial-in-ios-5-pinches-pans-and-more
例子代码:http://download.csdn.net/detail/totogo2010/5094059


UIGestureRecognizer手势识别详解 iOS应用开发过程,合理的使用手势识别功能来响应用户的操作,能够很好提升用户体验,为App增色。下面对UIGestureRecognizer手势进行一个比较全面的描述:      1、UIGestureRecognizer介绍            UIGestureRecognizer是手势识别的一个抽象类,没法直接使用。好心的苹果大神们已经为我们实现了常用的一些手势识别子类,具体列表如下: 阅读详情

相关推荐

UIGestureRecognizer学习之UIPinchGestureRecognizer(捏合)

UIPinchGestureRecognizer是UIGestureRecognizer的子类。 UIPinchGestureRecognizer除了继承UIGestureRecognizer的属性外,还提供如下俩个属性:scale: //获取捏合的比例 velocity: //获取捏合的速度示例:和前面的UITapGestureRecognizer的例子相似。- (void)viewDidLo

甫式人生 2939

UIPanGestureRecognizer进行视图滑动并处理手势冲突

首先我们肯定是给sourceVC的view上添加平移手势 UIPanGestureRecognizer 手势的实现方法中根据 Pan手势的三种状态 进行sourceVC的view的origin的处理 首先介绍一下 几个方法: 由于我们的sourceVC上存在tableview, 所以会导致tableview的滑动和pan滑动的 手势冲突 , 这也是为什么在上滑动过程中我屏蔽掉了tableview的scrollEnabled。但是当我们sourceVC滑动到上边界后,我们解开了tableview的滑动

Rey的技术博客 1506

【硬件开发】自举电路

半桥驱动电路中,下桥臂的源极直接接地,导通时栅极电压只需要达到MOS管导通d电压Vgs,但是对于上桥臂来说,上桥臂的源极电压会随着上桥臂的导通而抬升到VDD,对应想要导通时的栅极电压Vgs要到达Vgs+VDD。1,所有自举元件都位于栅极驱动器 IC 附近,可更大限度 地减小寄生电感的影响并减小自举电路的高峰值电流路径。栅极电压实现这个抬升的方法:使用电容两侧电压不能突变的特性,这个电容就是自举电容(也就是图中的C1)D1自举二极管的作用:防止升高的电压倒灌到原来的输入电压。快速恢复二极管或肖特基二极管。

weixin_62546664的博客 2845

iOS手势篇(五)-UIPanGestureRecognizer详解

UIPanGestureRecognizer是iOS开发中不怎么常用的一个拖动(拖拽)手势. 打开UIPanGestureRecognizer.h头文件 /// 属性 @property (nonatomic) NSUInteger minimumNumberOfTouches __TVOS_PROHIBITED; // default is 1. the minimum n...

MeteoriteMan的博客 1万+

新华硕笔记本ubuntu18.04双系统安装之后,wifi没有显示无法链接wifi

本来我以为跟简单安装一个wifi网卡的驱动就可以解决的问题,没想到花了我一早上的时候解决… 惭愧。 另外,本来是没打算写这篇博客的,但是我在搜索解决这个问题的过程中, 发现多人提出的解决方案跟我的都不一样,甚至我的解决方案都没有搜到相应的答案,还是只能靠自己啊。。 言归正传,还是说说怎么正确的安装wifi驱动吧! 1. wifi没有正确安装、或没有正确配置的表现 我的电脑现象: 有wifi图标, wifi设置上显示unaviable,无法搜索到任何wifi; 还有其他类似的表现,大家可以看看其他朋友的提

Ian的博客 1894

Python主要智能优化算法库汇总

最近几年简单浏览和对比了一些智能算法的库。现将各种库的主要信息、相关优缺点简单整理如下,各位同学可根据自己的需求和喜好进行选择。 文章目录1、DEAP2、mealpy3、scikit-opt (国产良心)4、Geat2(国产用心)5、pygmo26、pyswarms7、SciPy(想不到吧)小结 1、DEAP 项目地址:https://github.com/DEAP/deap 安装: pip install deap 优点: 起点高,发表在Journal of Machine Learning Rese

半个冯博士 2万+

UIGestureRecognizer的简单介绍

首先UIGestureRecognizer这个类包括7个子类 也就是7个手势    UITapGestureRecognier            轻敲手势    UIPinchGestureRecognier          捏合手势    UIRotationGestureRecognier       旋转手势    UISwipeGestureRe

WKFfantasy的博客 1205

树莓派Bookworm系统避坑指南:3种方法解决pip install报错externally-managed-environment

本文详细解析树莓派Bookworm系统中pip install报错externally-managed-environment的成因,并提供三种实用解决方案:使用虚拟环境(venv)隔离项目依赖、通过pipx管理全局Python工具,以及理解风险后的系统安装方法。帮助开发者安全高效地管理Python环境,避免系统冲突。

android的专栏 769

UIGestureRecognizer手势介绍

UIGestureRecognizer手势 : 1-概要介绍 一、UIGestureRecognizer类简介 UIGestureRecognizer类是一个抽象类,不能直接使用,具体使用过程中需要使用其子类。UIGestureRecognizer一共包括6个子类,分别对应6种手势,即: UITapGestureRecognizer:点击 UIP

小桥流水哗啦啦,iOS Coder 哒哒哒 845

在WSL2中配置代理(Windows)

通过按照上述步骤在WSL2中配置代理,我们可以轻松地在Windows子系统Linux中使用代理服务器访问互联网。请确保提供正确的代理服务器地址和端口号,并根据实际情况进行修改。在WSL2中使用代理是一个常见的需求,它允许我们在Windows子系统Linux中通过代理服务器访问互联网。本文将详细介绍如何在WSL2中配置代理,并提供相应的源代码示例。如果返回的IP地址与代理服务器所在地不同,说明代理正常工作。希望本文能对你有所帮助!如有其他问题,请随时向我提问。替换为实际的代理服务器地址和端口号。

FcUnity的博客 4361

1、UIGestureRecognizer介绍

1、UIGestureRecognizer介绍 手势识别在iOS上非常重要,手势操作移动设备的重要特征,极大的增加了移动设备使用便捷性。 iOS系统在3.2以后,为方便开发这使用一些常用的手势,提供了UIGestureRecognizer类。手势识别UIGestureRecognizer类是个抽象类,下面的子类是具体的手势,开发这可以直接使用这些手势识别。 UITapGestureRec

zhaojian3513的专栏 432

智能门禁:AI Agent的访客意图识别

随着人工智能技术的飞速发展,智能门禁系统已经成为现代安全管理的关键环节。本文深入探讨了AI Agent在访客意图识别中的应用,通过详细的分析和实例讲解,揭示了智能门禁系统的核心工作原理、算法实现及其在安全领域的重要作用。文章结构清晰,逻辑严谨,旨在为广大技术爱好者提供一次全面的技术盛宴。在当今社会,门禁系统已成为各类建筑和机构不可或缺的安全设施。随着信息安全意识的增强,传统门禁系统的局限性逐渐显现。例如,在访客管理方面,传统方法通常依赖于人工登记、身份验证等手段,不仅效率低下,而且容易出现漏洞。

AI架构师小马 716

UIGestureRecognizer 介绍

1、UIGestureRecognizer 介绍 手势识别在 iOS 中非常重要,他极大地提高了移动设备的使用便捷性。 iOS 系统在 3.2 以后,他提供了一些常用的手势(UIGestureRecognizer 的子类),开发者可以直接使用他们进行手势操作。 UIPanGestureRecognizer(拖动) UIPinchGestureRecognizer(捏合)

huzhaohao的专栏 1412

软考中级-软件设计师 知识点整理(一篇就过了 建议收藏)

软考中级-软件设计师上午题知识点总结

片言可决讼,半纸能缚龙 18万+

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

Swift UIGestureRecognizer介绍

UIGestureRecognizer UIGestureRecognizer是一个抽象类,定义了所有手势的基本行为,使用它的子类才能等到具体手势 UITapGestureRecognizer 敲击 UIPinchGestureRecognizer 捏合,用于缩放 UIPanGestureRecognizer 拖拽 UISwipeGestureRecognizer 轻扫 UIRot

EIamor的博客 6428

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

iOS触摸手势知识介绍(UITouch & UIGestureRecognizer)

1、触摸:代表着iOS用户交互的核心,它为用户与应用程序的交互提供了最重要的方式。触摸不只限于按钮触摸和键盘交互,可以设计和构建直接通过轻击或其他手势进行工作的应用程序。应用程序在试图类中接收、处理并响应触摸事件。   2、为什么是在视图类UIView中处理触摸事件而不是视图控制器UIViewController? 答:因为视图控制器可以拥有多个视图,所有视图都可能不同程度的使用

番薯大佬的专栏 1069

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

UIGestureRecognizer 6种手势用法介绍

UIGestureRecognizer 是一个具体手势的基类,提供了较为简单的手势实现方式   The concrete subclasses of UIGestureRecognizer are the following: UITapGestureRecognizer UIPinchGestureRecognizer UIRotationGest

yo__tao__的博客 2897

UIGestureRecognizer cancelsTouchesInView 手势的介绍

项目中遇到Tableview的区头上加了一个textfield,点击tableview让键盘收起,但是如果直接给tableview添加手势的话tableview didselect不执行,如果直接写touchEnd事件的话,由于tableview遮到了self.view所以touchEnd不会执行,一次在写手势的时候添加属性cancelsTouchesInView 当cancelsTouchesI

georgehenrywilliam的博客 546

IOS开发—7种常用手势UIGestureRecognizer介绍

7种常用手势UIGestureRecognizer介绍 [objc] view plaincopy #import "ViewController.h"    @interface ViewController ()   {       UITapGestureRecognizer *_tap;       UIPanGestureRec

Mr_Big_Kong的博客 774

[转]7种常用手势UIGestureRecognizer介绍

7种常用手势UIGestureRecognizer介绍

iOSTianNan的博客 960

iOS UIGestureRecognizer (手势的基本知识介绍)

手势识别在 iOS 中非常重要,他极大地提高了移动设备的使用便捷性。iOS 系统在 3.2 以后,他提供了一些常用的手势(UIGestureRecognizer 的子类),开发者可以直接使用他们进行手势操作。

测试必备,自由切换账号、环境的组件(swift) 583

IOS 的 7 中手势的介绍 和详细使用(UIGestureRecognizer) UIScreenEdgePanGestureRecognizer

在IOS的开发中,手势也是一个常常使用的,在上几年面试的时候,也会问到关于手势的问题。 IOS 开发有多少手势呢? 开发一共有 6 中手势(不包含,其他衍生手势 例如:UIScreenEdgePanGestureRecognizer ) 他们都是集成与 UIGestureRecognizer 第一步:效果图。 第二部:我们做变量和宏的定义。

风沙岁月 1666
上一篇: FMDatabaseQueue多线程操作
下一篇: NSNotificationCenter
SpringJustin
博客等级 码龄11年 2粉丝 44原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址