0330--iOS之UIEvent类

Class

UIEvent

An object that describes a single user interaction with your app.

      --描述单个用户交互的对象。
 

Declaration

class UIEvent : NSObject

Overview         --概览

Apps can receive many different types of events, including touch events, motion events, remote-control events, and press events. Touch events are the most common and are delivered to the view in which the touch originally occurred. Motion events are UIKit triggered and are separate from the motion events reported by the Core Motion framework. 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. Press events represent interactions with a game controller, AppleTV remote, or other device that has physical buttons. You can determine the type of an event using the type and subtype properties.

           --app可以接收许多不同类型的事件,包括触摸事件、运动事件、远程控制事件和按下事件。触摸事件是最常见的,它们被传递到触摸最初发生时的所在视图。运动事件是由UIKit触发的,与Core Motion框架报告的运动事件是分开的。远程控制事件允许应答器对象接收来自外部附件或耳机的命令,以便它能够管理音频和视频,例如播放视频或跳到下一个音轨。按下事件表示与游戏控制器、AppleTV遥控器或其他具有物理按钮的设备的交互。可以使用UIEvent的type and subtype属性确定事件的类型。

A touch event object contains the touches (that is, the fingers on the screen) that have some relation to the event. A touch event object may contain one or more touches, and each touch is represented by a UITouch object. When a touch event occurs, the system routes it to the appropriate responder and calls the appropriate method, such as touchesBegan(_:with:). The responder then uses the touches to determine an appropriate course of action.

            --触摸事件对象包含了与事件有关的若干个触摸(即屏幕上的手指)。一个触摸事件对象可以包含一个或多个触摸,每个触摸都由一个UITouch对象表示。当一个触摸事件发生时,系统将它路由到相应的响应器并调用相应的方法,例如touchesBegan(:with:)。然后响应者使用触摸来决定一个适当的动作过程。

During a multitouch sequence, UIKit reuses the same UIEvent object when delivering updated touch data to your app. You should never retain an event object or any object returned from an event object. If you need to retain data outside of the responder method you use to process that data, copy that data from the UITouch or UIEvent object to your local data structures.

          --在多点触控序列中,UIKit会重用相同的UIEvent对象,当向用户app传送更新的触控数据时。你不应保留event对象或从event对象返回的任何对象。如果需要保留响应者方法里面的数据,请从UITouch或UIEvent对象复制该数据到本地数据结构。

For more information on how to handle events in your UIKit app, see Event Handling Guide for UIKit Apps.

 

Topics            --专题

Getting the Touches for an Event                             --获取事件中的触摸对象

var allTouches: Set<UITouch>?

Returns all touches associated with the event.

func touches(for: UIView) -> Set<UITouch>?

Returns the touch objects from the event that belong to the specified given view.

func touches(for: UIWindow) -> Set<UITouch>?

Returns the touch objects from the event that belong to the specified window.

func coalescedTouches(for: UITouch) -> [UITouch]?

Returns all of the touches associated with the specified main touch.

func predictedTouches(for: UITouch) -> [UITouch]?

Returns an array of touches that are predicted to occur for the specified touch.

 

Getting Event Attributes                --获取事件的属性

var timestamp: TimeInterval

The time when the event occurred.

 

Getting the Event Type                          --获取事件类型

var type: UIEvent.EventType

Returns the type of the event.

var subtype: UIEvent.EventSubtype

Returns the subtype of the event.

 

Getting the Touches for a Gesture Recognizer             --获取手势识别器中的触摸对象

func touches(for: UIGestureRecognizer) -> Set<UITouch>?

Returns the touch objects that are being delivered to the specified gesture recognizer.

 

Constants            --常量

enum UIEvent.EventType

Specifies the general type of an event

enum UIEvent.EventSubtype

Specifies the subtype of the event in relation to its general type.

 

Instance Properties              --实例属性

var buttonMask: UIEvent.ButtonMask

var modifierFlags: UIKeyModifierFlags

 

Structures                      --数据结构

struct UIEvent.ButtonMask

Relationships

Inherits From

NSObject

Conforms To

See Also

First Steps

 

Using Responders and the Responder Chain to Handle Events

Learn how to handle events that propagate through your app.

class UIResponder

An abstract interface for responding to and handling events.

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值