手势

作者: 流水点点 | 来源:发表于2016-03-17 17:54 被阅读43次

UIresponder:响应者(传达者) 用来响应用户触摸屏幕的某些事件

标签:  UILabel

按钮:   UIButton

文本框:   UITextField

滚动视图:  UIScrollView

视图控制器: UIViewController

根视图:    RootViewController

分栏控制器:  UITabBarController

放图片的视图:   UIImageView

联系人通讯录:     UITableView

通讯录一行的视图 :UITableViewCell

滑动点点点点:     UIPageControl

用户的默认信息:      NSUserDefaults

手势分为六大手势:

   六大手势全部都继承自UIGestureRecognizer

1、点击UITapGestureRecognizer

2、长按UILongPressGestureRecognizer

3、拖拽UIPanGestureRecognizer

4、捏合UIPinchGestureRecognizer

5、轻扫UISwipeGestureRecognizer

6、旋转UIRotationGestureRecognizer

初始化手势

UITapGestureRecognizer*tap = [[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(actionOfTap:)];

设置点击手势的点击次数

tap.numberOfTapsRequired = 2;

设置点击手指的个数

tap.numberOfTouchesRequired = 2;

添加到视图是addGestureRecognizer: 而不是 addsubview:

[xx视图 addGestureRecognizer:xx手势];

minimumPressDuration设置长按的时间(多长时间才会调用长按触发事件)

1.手指开始触摸屏幕调用方法:- (void)touchesBegan:(NSSet *)touches withEvent:(nullable UIEvent *)event;

2.手指离开屏幕调用方法:- (void)touchesEnded:(NSSet *)touches withEvent:(nullable UIEvent *)event;

3.手指因外部事件取消触摸调用方法:- (void)touchesCancelled:(nullable NSSet *)touches withEvent:(nullable UIEvent *)event;

程序走的流程:用户点击屏幕触发->所有视图都继承UIResponder->UITuchBegin moved end

UITuchBegin moved end

获得点击视图的位置

CGPoint point = [xx手势locationInView:xx视图];

如果发现手势不调用.检查一下看是不是设置了背景颜色

相关文章

  • 手势

    点击手势 捏合手势 旋转手势 轻扫手势 拖拽手势 边缘平移手势 长按手势

  • iOS-手势详细参数说明

    敲击手势 长按手势 滑动手势 拖动手势 旋转手势 捏合手势 两种手势作用在同一个视图

  • 【iOS学习】——手势识别

    iOS 手势 手势需要开启用户交互 点击手势 单击手势 双击手势 添加 numberOfTapsRequired...

  • Swift - UIGestureRecognizer 各种手势

    1、点击手势2、拖动手势3、长按手势4、滑动手势5、捏合手势6、旋转手势 完整代码

  • iOS七种手势详解

    1、轻拍手势 2、捏合手势 3、旋转手势 4、平移手势 5、边缘轻扫手势 6、长按手势 7、轻扫手势 给image...

  • iOS手势总结

    1.轻拍手势 2.长按手势 3.轻扫手势 4.平移手势 5.捏合手势 6.旋转手势 7.边缘手势

  • iOS 手势

    修改时间: 2016-12-19修改次数: 0 手势传递 点击手势 捏合手势 轻扫手势 拖动手势 长按手势

  • iOS手势操作

    iOS手势有六种 手势类型: 手势状态: 创建View添加手势 1.轻点手势( UITapGestureRecog...

  • Vue手势

    点击手势 滑动手势 手势的方法

  • UI梳理——手势

    手势分类: 手势的创建: 方法的实现: 轻扫手势:UISwipeGestureRecognizer 长按手势: 以...

网友评论

      本文标题:手势

      本文链接:https://www.haomeiwen.com/subject/ojxtlttx.html