ios触摸事件一 :UIEvent
2015-12-18 10:01
537 查看
手机事件一般分为:
运动事件(如手机摇动等)、远程控制事件(如蓝牙等)、触摸事件(常用的屏幕点击)。
IOS通过检测用户的手势并对其做出回应,即可以与用户手势交互。
触摸的概念就不在解释了。触摸是在UIView(用户屏幕上的可视view)上进行的。实际上所有的UI控件都是直接继承或者间接继承自UIView,所以,所有的UI控件都可以产生触摸事件。 注意 import UIKit.
当用户触摸屏幕时,事件会被封装成一个UIEvent实例,其包含了触摸事件的相关信息。event实例中包含着若干UITouch实例,一个touch表示一个触点(手指)。
首先了解一下UITouch类。
官方文档解释:A UITouch object represents the location, size, movement, and force of a finger on the screen for a particular event. The force of a touch is available starting in iOS 9 on devices that support 3D Touch.
UITouch就表示了一个触点(手指触摸点)的响应属性。可以从其得到相关的数据,以便于处理。ios9增加了3Dtouch的效果。多了一个force(力度)属性。
当用户点击屏幕后,响应者会获取一个UIEvent对象,我们可以从其实例中获得UITouch对象。
A touch object includes accessors for:
The view or window in which the touch occurred
The location of the touch within the view or window
The approximate radius of the touch
The force of the touch (on devices that support 3D Touch)
UITouch类的常用属性: 继承了NSObject
(UITouch —–> NSObject)
再来了解一下UIEvent类。
![](http://img.blog.csdn.net/20151218115633109)
官方解释:A UIEvent object (or, simply, an event object) represents an event in iOS. There are three general types of event: touch events, motion events, and remote-control events.
远程控制事件: Remote-control events allow a responder object to receive commands from an external accessory or headset so that it can manage manage audio and video—for example, playing a video or skipping to the next audio track. Motion events were introduced in iOS 3.0 and remote-control events in iOS 4.0.
UIEvent类的常用属性:
(UIEvent —-> NSObject)
提示:以上内容均为个人理解,若有偏颇,望指正。多谢
运动事件(如手机摇动等)、远程控制事件(如蓝牙等)、触摸事件(常用的屏幕点击)。
IOS通过检测用户的手势并对其做出回应,即可以与用户手势交互。
触摸的概念就不在解释了。触摸是在UIView(用户屏幕上的可视view)上进行的。实际上所有的UI控件都是直接继承或者间接继承自UIView,所以,所有的UI控件都可以产生触摸事件。 注意 import UIKit.
当用户触摸屏幕时,事件会被封装成一个UIEvent实例,其包含了触摸事件的相关信息。event实例中包含着若干UITouch实例,一个touch表示一个触点(手指)。
首先了解一下UITouch类。
官方文档解释:A UITouch object represents the location, size, movement, and force of a finger on the screen for a particular event. The force of a touch is available starting in iOS 9 on devices that support 3D Touch.
UITouch就表示了一个触点(手指触摸点)的响应属性。可以从其得到相关的数据,以便于处理。ios9增加了3Dtouch的效果。多了一个force(力度)属性。
当用户点击屏幕后,响应者会获取一个UIEvent对象,我们可以从其实例中获得UITouch对象。
A touch object includes accessors for:
The view or window in which the touch occurred
The location of the touch within the view or window
The approximate radius of the touch
The force of the touch (on devices that support 3D Touch)
UITouch类的常用属性: 继承了NSObject
(UITouch —–> NSObject)
NS_CLASS_AVAILABLE_IOS(2_0) @interface UITouch : NSObject @property(nonatomic,readonly) NSUInteger tapCount; //获取很短时间内点击的次数。只读。 - (CGPoint)locationInView:(UIView *)view; //返回当前触点在指定view(参数)的位置。中心点,针对view坐标系 - (CGPoint)previousLocationInView:(UIView *)view; //该方法记录了前一个的坐标值,返回一个CGPoint类型的值,表示触摸在view这个视图上的位置,返回的位置是针对view的坐标系的。 /*英语扫盲:previous |ˈpriːvɪəs| adj : 先前的。*/ /*!!学号一门外语很重要!!*/ @end
再来了解一下UIEvent类。
官方解释:A UIEvent object (or, simply, an event object) represents an event in iOS. There are three general types of event: touch events, motion events, and remote-control events.
远程控制事件: Remote-control events allow a responder object to receive commands from an external accessory or headset so that it can manage manage audio and video—for example, playing a video or skipping to the next audio track. Motion events were introduced in iOS 3.0 and remote-control events in iOS 4.0.
UIEvent类的常用属性:
(UIEvent —-> NSObject)
@interface UIEvent : NSObject - (NSSet *)allTouches; //返回所有的touch (Set集合)!!!常用 - (NSSet *)touchesForWindow:(UIWindow *)window; //返回指定window上的一组touch(不常用) - (NSSet *)touchesForView:(UIView *)view;//返回事件的属于指定view的一组touch(不常用) - (NSSet *)touchesForGestureRecognizer:(UIGestureRecognizer *)gesture `NS_AVAILABLE_IOS(3_2);//返回指定手势所使用的一组touch(不常用) @end
提示:以上内容均为个人理解,若有偏颇,望指正。多谢
相关文章推荐
- iOS学习路线 iOS框架图 UI框架
- Incorrect datetime value: '' for column 'createtime'
- input标签name与value区别
- iPad UIPopoverController弹出窗口的位置和坐标
- Ueditor官方文档之上传路径配置
- iOS - UI: 动画汇总二(学习日记)
- iOS-UIKit( UIBezierPath.h - -应用举例)
- iOS的UI开发中Modal的使用与主流应用UI结构介绍
- Ueditor富编辑器第二次打开的时候会渲染失败
- sql 查询语法汇总(二)ExecuteReader、ExecuteNonQuery、ExecuteScalar、SqlDataReader、SqlDataAdapter
- android studio java.exe finished with non-zero exit value 2 解决思路与方法
- 图书馆信息化前沿技术网站Library technology guides
- 学习jQuey中的return false
- UIView动画(学习笔记)
- UVAlive4287 Proving Equivalences(scc)
- java中String,StringBuffer,StringBuilder之间的区别
- 使用Handler类来更新UI
- 学习jQuey中的return false
- iOS开发之UIlabel多行文字自动换行 (自动折行)
- iOS获取和监测设备基本信息——UIDevice的使用