[英]How to control the number of simultaneous touches on a view in iOS
I have a UIView which contains almost 10 buttons which performs different actions. 我有一个UIView,它包含几乎10个执行不同操作的按钮。 The user will be able to touch or tap on any button to perform a required action.
用户将能够触摸或点击任何按钮以执行所需的操作。 But, i am getting a problem when the user presses multiple buttons at the same time.
但是,当用户同时按下多个按钮时,我遇到了问题。 When two buttons are pressed at the same time(simultaneously) two actions are getting performed.
当同时按下两个按钮(同时)时,将执行两个动作。 Some times the app is getting crashed.
有时应用程序崩溃了。 So, i dont want the user to tap multiple buttons simultaneously.
所以,我不希望用户同时点击多个按钮。 Is there any way in which i can ask a view to recognize only single touch instead of multiple touches or at least can i increase the time gap between multiple touch gestures...
有什么方法我可以让视图只识别单个触摸而不是多个触摸,或者至少可以增加多个触摸手势之间的时间间隔......
Use button.exclusiveTouch = YES
; 使用
button.exclusiveTouch = YES
; on each of your buttons. 在每个按钮上。 You will need to hook them up to
UIButtons
and set the property in viewDidLoad
for example 您需要将它们连接到
UIButtons
并在viewDidLoad
设置属性
Try yourView.multipleTouchEnabled = NO;
试试
yourView.multipleTouchEnabled = NO;
"yourView" here is the view contents all of your buttons. “yourView”这里是所有按钮的视图内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.