取消触摸UIButton触摸移动(iOS) [英] Cancel touch on UIButton on touch move (iOS)
问题描述
如何在优雅按钮上取消触摸接收?
您需要实现UIGestureRecognizerDelegate。具体这个方法。然后只需建立你的逻辑来决定手势是否应该接受触摸。如果你返回NO,那么触摸就是为了抓住按钮。 (UIGestureRecognizer *)手势识别器shouldReceiveTouch :( UITouch *)触摸
如果你没有更多的控制,我认为你需要对按钮进行子类化和接管它的命中测试。
I have a view with button and touch-move gesture. When user touches button it becomes selected and keeps receiving touch-move events. I want to deselect the button on touch-move and pass moves to gesture.
How to cancel touch receiving on button "elegantly"?
You need to implement the UIGestureRecognizerDelegate. Specifically this method. Then just build your logic for deciding if the gesture should receive the touch or not. If you return NO then the touch is up for grabs for the button. if you return YES the gesture to take the touch.
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
If you never even more control I think you'll need to subclass the button and takeover its hit testing.
这篇关于取消触摸UIButton触摸移动(iOS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!