与其他用户界面控件交互

UIControl子类会覆盖parentView的gesture.例如当用户点击UIButton时,UIButton会接受触摸事件,它的parentView不会接收到.这仅适用于手势识别重叠的默认动作的控制,其中包括:

  • 一根手指单击动作:UIButton, UISwitch, UIStepper, UISegmentedControl, and UIPageControl.
  • 一根手指擦碰动作:UISlider
  • 一根手指拖动动作:UISwitch

  包含多点触摸的事件

在iOS中,touch是指一根手指在屏幕上滑动、移动.而手势是指有一根或多根手指,它的类是UITouch对象.多点触摸事件是UIEventTypeTouches

 

当发生触摸时,会触发下列方法:

  • touchesBegan:withEvent :触摸屏幕时发生
  • touchesMoved:withEvent :手指在屏幕上移动时发生
  • touchesEnded:withEvent :触摸结束时发生,即手指离开屏幕时
  • touchesCancelled:withEvent :触摸被系统取消时发生,如有电话时,该触摸会被取消

改变默认的事件传递顺序

你可以通过改变UIGestureRecognizer子类的属性来改变默认的事件传递

  • @property(nonatomic) BOOL delaysTouchesBegan;         // default is NO.  causes all touch events to be delivered to the target view only after this gesture has failed recognition. set to YES to prevent views from processing any touches that may be recognized as part of this gesture
  • @property(nonatomic) BOOL delaysTouchesEnded;         // default is YES. causes touchesEnded events to be delivered to the target view only after this gesture has failed recognition. this ensures that a touch that is part of the gesture can be cancelled if the gesture is recognized

如果一个gesture recognizer检测到了一个不属于它的touch,它将手势直接发送给它的view,此时会调用ignoreTouch:forEvent: 方法直接传递给view.

创建自定义gesture recognizer步骤

  • 创建UIGestureRecognizer的子类
  • #import <UIKit/UIGestureRecognizerSubclass.h>
  • 在子类冲重载下列方法
1.- (void)reset;
2.- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
3.- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
4.- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
5.- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;

iOS开发之手势gesture详解(二)的更多相关文章

  1. 【转】 iOS开发之手势gesture详解

    原文:http://www.cnblogs.com/salam/archive/2013/04/30/iOS_gesture.html 前言 在iOS中,你可以使用系统内置的手势识别 (Gesture ...

  2. iOS开发之手势gesture详解(一)

    前言 在iOS中,你可以使用系统内置的手势识别(GestureRecognizer),也可以创建自己的手势.GestureRecognizer将低级别的转换为高级别的执行行为,是你绑定到view的对象 ...

  3. iOS开发摇动手势实现详解

    1.当设备摇动时,系统会算出加速计的值,并告知是否发生了摇动手势.系统只会运动开始和结束时通知你,并不会在运动发生的整个过程中始终向你报告每一次运动.例如,你快速摇动设备三次,那只会收到一个摇动事件. ...

  4. iOS 开发之照片框架详解之二 —— PhotoKit 详解(下)

    本文链接:http://kayosite.com/ios-development-and-detail-of-photo-framework-part-three.html 这里接着前文<iOS ...

  5. iOS 开发之照片框架详解之二 —— PhotoKit 详解(上)

    转载自:http://kayosite.com/ios-development-and-detail-of-photo-framework-part-two.html 一. 概况 本文接着 iOS 开 ...

  6. iOS 开发之照片框架详解(2)

    一. 概况 本文接着 iOS 开发之照片框架详解,侧重介绍在前文中简单介绍过的 PhotoKit 及其与 ALAssetLibrary 的差异,以及如何基于 PhotoKit 与 AlAssetLib ...

  7. iOS 开发之照片框架详解

    转载自:http://kayosite.com/ios-development-and-detail-of-photo-framework.html 一. 概要 在 iOS 设备中,照片和视频是相当重 ...

  8. iOS开发——UI篇&ScrollView详解

    创建方式 1:StoryBoard/Xib 这里StoarBoard就不多说,直接拖就可以,说太多没意思,如果连这个都不会我只能先给你跪了! 2:代码: CGRect bounds = [ [ UIS ...

  9. IOS开发中单例模式使用详解

    第一.基本概念 单例模式是一种常用的软件设计模式.在它的核心结构中只包含一个被称为单例类的特殊类.通过单例模式可以保证系统中一个类只有一个实例而且该实例易于外界访问. 第二.在IOS中使用单例模式的情 ...

随机推荐

  1. Race condition

    在很多门课上都接触到race condition, 其中也举了很多方法解决这个问题.于是想来总结一下这些方法. Race condition 它旨在描述一个系统或者进程的输出依赖于不受控制的事件出现顺 ...

  2. deque 用法

    引用博客:https://blog.csdn.net/zyq522376829/article/details/46801973 下面是那位大佬写的的笔记整理~~~~ deque - 双向队列 1.构 ...

  3. Bzoj 3450: Tyvj1952 Easy (期望)

    Bzoj 3450: Tyvj1952 Easy 这里放上题面,毕竟是个权限题(洛谷貌似有题,忘记叫什么了) Time Limit: 10 Sec Memory Limit: 128 MB Submi ...

  4. Java AES加密解密工具 -- GUI 、在线传输文件

    原理 对于任意长度的明文,AES首先对其进行分组,每组的长度为128位.分组之后将分别对每个128位的明文分组进行加密. 对于每个128位长度的明文分组的加密过程如下:     (1)将128位AES ...

  5. 用Python设置matplotlib.plot的坐标轴刻度间隔以及刻度范围

    一.用默认设置绘制折线图 import matplotlib.pyplot as plt x_values=list(range(11)) #x轴的数字是0到10这11个整数 y_values=[x* ...

  6. PAT Basic 1075

    1075 链表元素分类 给定一个单链表,请编写程序将链表元素进行分类排列,使得所有负值元素都排在非负值元素的前面,而 [0, K] 区间内的元素都排在大于 K 的元素前面.但每一类内部元素的顺序是不能 ...

  7. selenium2等待元素加载

    1.硬性等待 Thread.sleep(8000); 所谓的硬性等待就是,执行完相应操作就等待我设置的8s.无论网速快与慢,网速快的话,也许5s就打开网页了,可是程序必须接着等待剩下的3秒. 网速慢的 ...

  8. flask-用户资料

    首先创建User模型 class User(UserMixin,db.Model): __tablename__ = 'users' #.. name = db.Column(db.String(64 ...

  9. 细嚼慢咽 Mongoose 5

    此文已由作者黄锴授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 前言 由于Mongoose一直没有中文文档,加上现在市面上充斥着太多"快速上手",很多中文 ...

  10. zuul session 不一致的问题

    配置文件: #不加这句话导致session不一致zuul.routes.intelligentsia-authority.sensitiveHeaders = Authorization 过滤器里面 ...