天天看點

如何“排外”處理多點觸摸事件

    經常有網友問,如何避免同時處理多個多點觸摸事件?實際上,在Apple的官方文檔中已經提供了解決方案。

    Apple在UIView的multipleTouchEnabled屬性的讨論中提到:如果你希望這個視圖“排外”處理多點觸摸事件,隻需要把組的這一屬性,屬性的值是multipleTouchEnabled和exclusivetouch的值同時設為YES。

multipleTouchEnabled
A Boolean value that indicates whether the receiver handles multi-touch events.

@property(nonatomic, getter=isMultipleTouchEnabled) BOOL multipleTouchEnabled
Discussion
When set to YES, the receiver receives all touches associated with a multi-touch sequence. When set to NO, the receiver receives only the first touch event in a multi-touch sequence. The default value of this property is NO.

Other views in the same window can still receive touch events when this property is NO. If you want this view to handle multi-touch events exclusively, set the values of both this property and the exclusiveTouch property to YES.

Availability
Available in iOS 2.0 and later.
See Also
  @property exclusiveTouch
Related Sample Code
aurioTouch2
Declared In
UIView.h