Ios 同时查看手势交互
我在Ios 同时查看手势交互,ios,swift,uicollectionview,uitextview,uigesturerecognizer,Ios,Swift,Uicollectionview,Uitextview,Uigesturerecognizer,我在uicollectionviewcell中有一个uitextview,它覆盖了大部分视图 我的目标是。。。 1.上下滚动查看uitextviewtext。 2.点击uicollectionviewcell执行另一项功能 现在它要么是,要么不是两者都是。我尝试启用多点触摸、同时手势交互、向uitextview添加tapgesturerecognizer等,但找不到任何现有的解决方案。下面是我的一些简单代码 func collectionView(_ collectionView: UIColl
uicollectionviewcell
中有一个uitextview
,它覆盖了大部分视图
我的目标是。。。
1.上下滚动查看uitextview
text。
2.点击uicollectionviewcell
执行另一项功能
现在它要么是,要么不是两者都是。我尝试启用多点触摸、同时手势交互、向uitextview
添加tapgesturerecognizer
等,但找不到任何现有的解决方案。下面是我的一些简单代码
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
//do something
}
func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) {
//do something
}
func addTapGesture(_ cell: TestCollectionViewCell, _ indexPath: IndexPath) {
cell.textView.tag = indexPath.item
cell.textView.gestureRecognizers = []
tap = UITapGestureRecognizer(target: self, action: #selector(onTap))
tap.delegate = self
cell.textView.addGestureRecognizer(tap)
cell.textView.isScrollEnabled = true
}
@objc func onTap(_ sender: UITapGestureRecognizer) {
//do something
}
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
您的textView是否可编辑?@Bhavesh.iosDev既不可编辑也不可选择我认为如果textView覆盖整个页面,您应该使用CollectionView didSelectMethodcell@Bhavesh.iosDev我正在使用该委托方法,我想知道如何将其与uitextview Scroll结合使用。当用户点击TextView时,您想做什么