`
lizaochengwen
  • 浏览: 659654 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

UIEvent

 
阅读更多

继承自: UIResponder : NSObject
遵 循: NSObject (NSObject)
框 架: /System/Library/Frameworks/UIKit.framework
可用平台: iPhone OS 2.0 或者更新
接口类: UIEvent.h
关联例子: aurioTouch
GLPaint
MoveMe
Touches

目录 [隐藏]
1 Overview
2 Tasks
2.1 Getting the Touches for an Event
2.2 Getting Event Attributes
3 Properties
3.1 timestamp
4 Instance Methods
4.1 allTouches
4.2 touchesForView:
4.3 touchesForWindow:
[编辑]
Overview

概述
A UIEvent object (or, simply, an event object) represents an event in iPhone OS. An event object contains one or more touches (that is, finger gestures on the screen) that have some relation to the event. A touch is represented by a UITouch object.
一个UIEvent对象(或者,简单的事件对象)在iPhone OS中变现为事件。一个事件对象包含一个或者多个触摸(那是,手指在屏幕上的交互)关联事件。一个触摸事件表现为一个UITouch对象。
When an event occurs, the system routes it to the appropriate responder and passes in the UIEvent object in a message invoking a UIResponder method such as touchesBegan:withEvent:. The responder can then evaluate the touches for the event or for a particular phase of the event and handle them appropriately. The methods of UIEvent allow you to obtain all touches for the event (allTouches) or only those for a given view or window (touchesForView: or touchesForWindow:). It can also distinguish an event object from objects representing other events by querying an object for the time of its creation (timestamp).
当一个事件触发了,系统将会把它传递给合适的响应对象并通过UIEvent对象发出一个消息调用UIResponder方法如 touchesBegan:withEvent: 。响应对象可以分配触摸事件到合适的触摸类型并适当的控制他们。UIEvent中的方法可以让你获取全部的触摸事件或者给定的视图或者窗口(touchesForView: 或者 touchesForWindow:)。它可以分辨从响应对象传递过来的事件对象发生的时间(timestamp)。
A UIEvent object is persistent throughout a multi-touch sequence; UIKit reuses the same UIEvent instance for every event delivered to the application. You should never retain an event object or any object returned from an event object. If you need to keep information from an event around from one phase to another, you should copy that information from the UITouch or UIEvent object.
一个UIEvent对象贯穿在多点触摸事件的序列中;UIKit 重用同一个UIEvent实例来分配每一个事件到应用程序。你不需要保持一个事件对象或者任何从事件对象返回的对象。如果你需要保存事件对象然後传递到另外一个对象,你需要从UITouch或者UIEvent中复制信息。
See "Event Handling" in iPhone Application Programming Guide for further information on event handling.
有关更多事件控制的信息你可以查看 iPhone Application Programming Guide 中的事件控制一章。
[编辑]
Tasks

任务
[编辑]
Getting the Touches for an Event
获取事件中的触摸对象
– allTouches
– touchesForView:
– touchesForWindow:
[编辑]
Getting Event Attributes
获取事件属性
timestamp  property

[编辑]
Properties

属性
For more about Objective-C properties, see “Properties” in The Objective-C 2.0 Programming Language.
更多有关Objective-C属性的信息,请看The Objective-C 2.0 Programming Language中的"Properties"这一章
[编辑]
timestamp
The time when the event occurred. (read-only)
事件发生的时间。(只读)
@property(nonatomic, readonly) NSTimeInterval timestamp
Discussion
讨论
The property value is the number of seconds since system startup.
这个属性的值是一个数字当系统启动的时候。
Availability
可用平台
Available in iPhone OS 2.0 and later.
可用于iPhone OS 2.0或者更新
Declared In
定义文件
UIEvent.h
[编辑]
Instance Methods

实例方法
[编辑]
allTouches
Returns all touch objects associated with the receiver.
返回和接收者有关的所有触摸对象
- (NSSet *)allTouches
Return Value
返回值
A set of UITouch objects representing all touches associated with an event (represented by the receiver).
一个UITouch对象的集合包含所有的触摸事件(取决于那个接收者)
Discussion
讨论
If the touches of the event originate in different views and windows, the UITouch objects obtained from this method will have different responder objects associated with the touches.
如果事件的触摸对象来自不同的视图或者窗口,那UITouch对象将会从不同的响应对象中获取触摸事件。
Availability
可用平台
Available in iPhone OS 2.0 and later.
可用于iPhone OS 2.0或者更新
See Also
同类参考
– touchesForView:
– touchesForWindow:
Related Sample Code
关联的例子代码
aurioTouch
Metronome
Declared In
定义文件
UIEvent.h

[编辑]
touchesForView:
Returns the touch objects that belong to a given view for the event represented by the receiver.
返回属于接收者给定的视图的事件响应的触摸对象
- (NSSet *)touchesForView:(UIView *)view
Parameters
参数
view
The UIView object on which the touches related to the event were made.
一个关联触摸事件发生的UIView对象
Return Value
返回值
An set of UITouch objects representing the touches for the specified view related to the event represented by the receiver.
接收者关联视图的事件响应者发出的UITouch对象集合
Availability
可用平台
Available in iPhone OS 2.0 and later.
可用于iPhone OS 2.0或者更新
See Also
同类参考
– allTouches
– touchesForWindow:
Related Sample Code
关联的例子代码
GLPaint
Declared In
定义文件
UIEvent.h

[编辑]
touchesForWindow:
Returns the touch objects that belong to a given window for the event represented by the receiver.
返回接收者给定的窗口的触摸事件的事件响应对象
- (NSSet *)touchesForWindow:(UIWindow *)window
Parameters
参数
window
The UIWindow object on which the touches related to the event were made.
一个发生触摸事件关联的UIWindow对象
Return Value
返回值
An set of UITouch objects representing the touches for the specified window related to the event represented by the receiver.
接收者关联窗口的事件响应者发出的UITouch对象集合
Availability
可用平台
Available in iPhone OS 2.0 and later.
可用于iPhone OS 2.0或者更新
See Also
同类参考
– allTouches
– touchesForView:
Declared In
定义文件
UIEvent.h
分享到:
评论

相关推荐

    ios响应链测试demo

    ios事件响应链,重写- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event以及- (BOOL)pointInside:(CGPoint)point withEvent:(nullable UIEvent *)event方法来查看系统响应事件的逻辑

    IOS 开发之触摸事件详细介绍

    1. `- (void)touchesBegan:(NSSet*> *)touches withEvent:(UIEvent *)event;`:当一个或多个手指首次接触屏幕时,系统会调用此方法。`touches`参数包含所有当前触碰屏幕的UITouch对象,`event`参数包含了整个事件的...

    iOS 使用UITouch移动方块

    override func touchesBegan(_ touches: Set, with event: UIEvent?) { guard let touch = touches.first else { return } touchStartPoint = touch.location(in: self) } override func touchesMoved(_ ...

    深入浅析IOS中UIControl

    首先,UIEvent是iOS系统中处理触摸事件的核心对象,它封装了一系列的UITouch实例,代表用户的触摸动作。在iOS的事件模型中,当用户与屏幕交互时,事件会沿着响应者链(UIResponder Chain)从最上层的窗口对象向下...

    iOS-Event Programming Guide

    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { // 在这里处理触摸开始时的动作 } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { // 在这里处理手指移动时的动作 }...

    iOS开发手势问题

    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"touchesBegan"); } ``` 2. **touchesMoved:** 当一个或多个手指在屏幕上滑动时被触发。 - **示例代码**: ```objective-c -(void...

    ios-鹏哥哥放大镜.zip

    (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ self.touchTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(addView) userInfo:nil repeats:NO];...

    Javascript中的事件--Event对象

    #### MouseEvent进一步扩展了UIEvent,提供了鼠标事件特有的属性: - **`button`**:表示触发事件的鼠标按钮(0表示左键,1表示中键,2表示右键)。 - **`altKey`、`ctrlKey`、`shiftKey`、`metaKey`**:这些布尔值...

    IOS应用源码之ios触摸事件例子全集.rar

    override func touchesBegan(_ touches: Set, with event: UIEvent?) { // 处理触摸开始的逻辑 } override func touchesMoved(_ touches: Set, with event: UIEvent?) { // 处理触摸移动的逻辑 } override func ...

    Event Handling Guide for iOS 官方文档1

    2. **UIEvent对象**:UIEvent封装了各种事件,如单个触摸、摇动或远程控制操作。它包含了事件的所有相关信息,使得应用程序可以适当地响应。 3. **多点触控事件**:当用户与应用的视图进行交互时,应用会接收到多点...

    第八节 检测屏幕触摸事件.docx

    1. `- (void)touchesBegan:(NSSet*> *)touches withEvent:(UIEvent *)event;` 这个方法在用户手指首次接触屏幕时被调用。`touches`参数是一个NSSet对象,包含了所有在该事件中开始触摸的UITouch对象。`event`参数则...

    【iOS-Cocos2d游戏开发】触屏事件处理机制

    此外,还需要实现`-(void)ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event`和`-(void)ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event`方法,分别处理触摸移动和触摸结束的事件。 总的来说,...

    iPhone按钮特效代码

    - `- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event`处理触摸开始事件。 - `- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event`处理触摸移动事件。 - `- (void)touchesEnded...

    ios-点击超出父视图的子视图可以响应事件.zip

    - `- (void)touchesBegan:(NSSet*> *)touches withEvent:(UIEvent *)event;` - `- (void)touchesMoved:(NSSet*> *)touches withEvent:(UIEvent *)event;` - `- (void)touchesEnded:(NSSet*> *)touches withEvent:...

    IOS应用源码Demo-手势和触摸-毕设学习.zip

    override func touchesBegan(_ touches: Set, with event: UIEvent?) { // 触摸开始时的动作 } override func touchesMoved(_ touches: Set, with event: UIEvent?) { // 触摸移动时的动作 } override func ...

    ios-TabBar超出范围按钮能点击.zip

    YSTabBarOutSide文件夹:控件... override func point(inside point: CGPoint, with event: UIEvent?) -> Bool { for item in subviews{ if item.frame.contains(point){ return true } } return false }

    cocos2d事件响应总结

    - `touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event` - `touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event` - `touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event` - `...

    (0109)-iOS/iPhone/iPAD/iPod源代码-按钮(Button)-keyboard Button

    通过重写`- (void)touchesBegan:(NSSet*> *)touches withEvent:(UIEvent *)event`、`- (void)touchesMoved:(NSSet*> *)touches withEvent:(UIEvent *)event`、`- (void)touchesEnded:(NSSet*> *)touches withEvent:...

    iOS 小画板

    描述中的代码片段`-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event`是Objective-C语言中处理触摸开始事件的关键方法,它属于UIResponder类的一部分,是所有可以响应用户交互的iOS对象的基类。...

Global site tag (gtag.js) - Google Analytics