[英]How to deselect View from multiple view When Select new one using gesture recognizer in swift?
How to select a view from multiple view and previous selected will be deselect using TapgestureRecognizer ? 如何从多个视图中选择一个视图,而先前选择的视图将使用TapgestureRecognizer取消选择?
@objc func tapGestureHandler(gesture: UITapGestureRecognizer){
if drawView.isUserInteractionEnabled == true{
return
}
if gesture.state == UIGestureRecognizer.State.ended{
if let embedTextView = gesture.view as? EmbedTextView {
textMode()
self.textTools.editingTarget = embedTextView
}
}
self.stampFrame.borderWidth = 1
self.stampFrame.borderColor = UIColor.black
}
要在集合视图中取消选择:-
collectionView.deselectItem(at: indexPath, animated: false)
// Get index from tap gesture , for did deselect //从点击手势获取索引,取消选择
@objc func tapBlurButton(_ sender: UILongPressGestureRecognizer) {
let location = sender.location(in: collectionView) // point of touch in collectionView
if let indexPath = collectionView.indexPathForItem(at: location) { // indexPath of touch location
let indexPaths = IndexPath(item: indexPath , section: 0)
collectionView.selectItem(at: indexPaths, animated: true, scrollPosition: .top)
collectionView.delegate?.collectionView!(collectionView, didDeselectItemAt: indexPaths)
}
}
// Hope it works for you! // 希望这对你有用! thanks
谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.