Events and Event Types
An event is an object that represents a user event that is, a user action that iPhone OS detects, such as the touch of a finger or a shake of the device. In Cocoa Touch, events are instances of the UIEvent class. An event object may encapsulate state related to the user event, such as the associated touches. As a user event takes place for example, as fingers touch the screen and move across its surface the system continually sends event objects to an application for handling.
iPhone OS currently supports two types of events: touch events and motion events. The UIEvent class has been extended for iPhone OS 3.0 to accommodate not only these types of events but future kinds of events as well. It declares the enum constants shown in Program.
Event-type and event-subtype constants
typedef enum {
UIEventTypeTouches,
UIEventTypeMotion,
} UIEventType;
typedef enum {
UIEventSubtypeNone = 0,
UIEventSubtypeMotionShake = 1,
} UIEventSubtype;
iPhone OS currently supports two types of events: touch events and motion events. The UIEvent class has been extended for iPhone OS 3.0 to accommodate not only these types of events but future kinds of events as well. It declares the enum constants shown in Program.
Event-type and event-subtype constants
typedef enum {
UIEventTypeTouches,
UIEventTypeMotion,
} UIEventType;
typedef enum {
UIEventSubtypeNone = 0,
UIEventSubtypeMotionShake = 1,
} UIEventSubtype;
Each event has one of these event type and subtype constants associated with it, which you can access through the type and subtype properties of UIEvent. The event type includes both touch events and motion events. In iPhone OS 3.0, there is only a shake-motion subtype (UIEventSubtypeMotionShake);
touch events always have a subtype of UIEventSubtypeNone.
You should never retain a UIEvent object in your code. In you need to preserve the current state of an event
object for later evaluation, you should copy and store those bits of state in an appropriate manner (using an
instance variable or a dictionary object).
touch events always have a subtype of UIEventSubtypeNone.
You should never retain a UIEvent object in your code. In you need to preserve the current state of an event
object for later evaluation, you should copy and store those bits of state in an appropriate manner (using an
instance variable or a dictionary object).
No comments:
Post a Comment