zoukankan      html  css  js  c++  java
  • 触摸事件

    iOS中的可以分为3大类型 :触摸事件  加速计事件  远程控制事件

    在iOS中不是任何对象都能处理事件,只有继承了UIResponder的对象才能接收并处理事件.我们称之为“响应者对象”

    UIResponder内部提供了以下方法来处理事件

    触摸事件(系统会自动调用)

    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; //手指按下

    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; //手指移动

    - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event; //手指抬起

    - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event; //意外中断事件(电话打扰)

    提示:touches中存放的都是UITouch对象

    触摸事件的处理

    UIView是UIResponder的子类,可以覆盖下列4个方法处理不同的触摸事件。

    1. 一根或者多根手指开始触摸屏幕

    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

    2.一根或者多根手指在屏幕上移动(随着手指的移动,会持续调用该方法)

    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event

    3.一根或者多根手指离开屏幕

    - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

    4.触摸结束前,某个系统事件(例如电话呼入)会打断触摸过程

    - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event

  • 相关阅读:
    sql server 扩展存储过程
    SQL SERVER 数据导出JSON
    Jquery AJAX ASP.NET IIS 跨域 超简单解决办法
    切换 NPM 镜像源
    HTML 简介
    mongoose 安装及配置
    Windows下MongoDB的安装过程及基本配置
    Node.js中npm常用命令大全
    --nodejs详细安装步骤
    Go语言为何说它优雅?-- Golang中的几个常用初始化设计
  • 原文地址:https://www.cnblogs.com/ritian/p/5193925.html
Copyright © 2011-2022 走看看