UICollectionViewCell中UILongPressGestureRecognizer触发失败,日志提示System gesture gate timed out的问题求助
UICollectionViewCell中UILongPressGestureRecognizer触发失败,日志提示System gesture gate timed out的问题求助
大家好,我碰到了一个手势识别的问题,想请各位帮忙看看:
我有一个UICollectionViewController,它的单元格结构是这样的:每个UICollectionViewCell里包含一个UIImageView、一个UILabel和一个UITableView,布局示意图如下:
+--------------------------------------------------------------------+ | | | +-------------Cell-------------+ +-------------Cell-------------+ | | | | | | | | | +-------+ | | +-------+ | | | | | Image | Label | | | Image | Label | | | | +-------+ | | +-------+ | | | | | | | | | | +--------------------------+ | | +--------------------------+ | | | | | | | | | | | | | | | TableView | | | | TableView | | | | | | | | | | | | | | | +--------------------------+ | | +--------------------------+ | | | +------------------------------+ +------------------------------+ | : : +--------------------------------------------------------------------+
我在UICollectionViewCell的子类中,给UIImageView添加了长按手势识别器,代码是这样的:
@IBOutlet private weak var imageView: UIImageView! { didSet { let gr = UILongPressGestureRecognizer(target: self, action: #selector(self.settingsButtonTouched)) imageView.gestureRecognizers?.append(gr) } }
目前来看这段代码逻辑没什么问题,但当我长按这个imageView的时候,绑定的settingsButtonTouched方法根本没被触发,反而控制台日志里出现了这么一行提示:
[SystemGestureGate] <0x129f2ab10> Gesture: System gesture gate timed out.
我搜了相关的解决方案,结果大多都是针对SwiftUI的,但我这个项目并没有使用SwiftUI,所以想问问有没有大佬知道这是什么原因导致的,以及该怎么解决这个问题?
备注:内容来源于stack exchange,提问作者D. Mika
相关产品推荐
相关产品推荐

