ios - 2 个同步的 UILongPressGestureRecognizer

标签 ios objective-c uikit uigesturerecognizer uilongpressgesturerecogni

我希望当用户用两根手指触摸屏幕时,两个单独的 UILongPressGestureRecognizers 可以识别每根手指的手势(1 个识别器用于 1 个手指)。我可以使用单个 UILongPressGestureRecognizer 并将 numberOfTouchesRequired 设置为 2,但我需要独立识别 2 个触摸(例如:我可以松开一根手指,另一个识别器将保持事件状态,这对于单个手势识别器是不可能的)。

感谢您的帮助。

最佳答案

要让两种手势协同工作,请实现以下委托(delegate)方法:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{
    return YES;
}

要使长按优先,请执行以下操作:

[tapGesture requireGestureRecognizerToFail:longPress];

关于ios - 2 个同步的 UILongPressGestureRecognizer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36560890/

相关文章:

ios - Xcode 中用于温度监控的仪器

javascript - Cordova/Phonegap oauth.io 弹出窗口未显示

iOS 委托(delegate)方法定义语法

iphone - 旋转 UIPickerView,可能吗?

iphone - 使用场景转换动画化 UIKit 项目

iphone - 如何从 UIImage 中 NSLog 像素 RGB?

iOS 富通知 : Sending MP4 files result in transparent thumbnails

iphone - [self.view addSubview :_topViewController. View ];自转问题

objective-c - "Couldn' t 编译连接 :"error mean? 是什么意思

objective-c - 自定义 View 中的中心按钮