Swift “如何检测电池上的双重抽头”;“只为一根手指”;在UICollectionView中?
我有一个Swift “如何检测电池上的双重抽头”;“只为一根手指”;在UICollectionView中?,swift,uitapgesturerecognizer,Swift,Uitapgesturerecognizer,我有一个UICollectionView包含很多单元格 我实现了两个功能: 单独点击单元格:点击视图 双击单元格:按B视图 问题是: 如果我同时单独点击两个(或更多)单元格,它只会按1视图。在这种情况下没关系 但是,如果我同时双击两个(或更多)单元格,它会逐个推送2个(或更多)B视图。这会导致意外行为,应用程序有时会崩溃 当有2个以上的单元格被点击时,如何禁用其他单元格以接收双重点击,并且只允许按下“1b视图” 我添加了doubletapsignate.numberOfTouchesRequir
UICollectionView
包含很多单元格
我实现了两个功能:
doubletapsignate.numberOfTouchesRequired=1
,但它不起作用
这是我的密码:
@objc private func didReceiveDoubleTap(uu-sender:ASCellNode){
self.doubleTapDelegate?.mycellwasdubletaped?(self)
}
重写func didLoad(){
super.didLoad()
让DoubleTap手势=UITapGestureRecognitor(目标:自我,操作:#选择器(MyCollectionCell.didReceiveDoubleTap(:))
DoubleTapSpirate.numberOfTapsRequired=2
DoubleTapSirture.delaysTouchesBegan=true
self.view.addGestureRecognitor(双击手势)
}
查看是否可以通过布尔检查防止多次调用委托方法
@objc private func didReceiveDoubleTap(_ sender: ASCellNode) {
if !processing {
processing = true // set processing = false where it's safe to do so.
self.doubleTapDelegate?.myCellWasDoubleTapped?(self)
}
}
查看是否可以通过布尔检查防止多次调用委托方法
@objc private func didReceiveDoubleTap(_ sender: ASCellNode) {
if !processing {
processing = true // set processing = false where it's safe to do so.
self.doubleTapDelegate?.myCellWasDoubleTapped?(self)
}
}