如何避免 UIView 上的多点触控
How to avoid multitouch on a UIView
我有一个包含多个 UIButtons
的视图。在 Interface Builder 中,框 Multiple Touch
未选中视图和按钮。我从不以编程方式激活多点触控。尽管如此,我仍然可以同时 select(按下)多个按钮,这显然会产生如此奇怪的结果。
为什么我没有激活 Multi Touch 时它会这样?
为您的按钮设置exclusiveTouch = YES
苹果 multipleTouchEnabled 文档
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.
您可以通过以下代码行同时停止多个按钮触摸。
SWIFT 3.0:
tempButton.isExclusiveTouch = true
默认情况下,它的值设置为 false
。
我有一个包含多个 UIButtons
的视图。在 Interface Builder 中,框 Multiple Touch
未选中视图和按钮。我从不以编程方式激活多点触控。尽管如此,我仍然可以同时 select(按下)多个按钮,这显然会产生如此奇怪的结果。
为什么我没有激活 Multi Touch 时它会这样?
为您的按钮设置exclusiveTouch = YES
苹果 multipleTouchEnabled 文档
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.
您可以通过以下代码行同时停止多个按钮触摸。
SWIFT 3.0:
tempButton.isExclusiveTouch = true
默认情况下,它的值设置为 false
。