【发布时间】:2018-04-11 05:06:21
【问题描述】:
我有一个加载产品列表的集合视图,其中没有花哨的功能。它只是从 API 加载数据。问题是当我尝试点击集合视图中的一项时
collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
没有被调用。但是当我长按一个单元格时,它会被调用。
我很确定单元格上没有应用手势。
谁能给我一些指导来解决这个问题。
我的代码库如下
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let cellTapped = (self.storeSearchListingCollectionViewOutlet.cellForItem(at: indexPath)) as! StoreSearchProdListingCollectionViewCell
UStoreShareClass.storeSharedInstance.longTappedProductID = String(cellTapped.tag)
if((UStoreShareClass.storeSharedInstance.longTappedProductID) != nil)
{
self.performSegue(withIdentifier: "searchToProductDetailSegue", sender: self)
}
else
{
SetDefaultWrappers().showAlert(info:SERVER_DOWN_ERROR_ALERT, viewController: self)
}
}
View Hierarchy如下
在此先感谢...!!!
【问题讨论】:
-
您的视图层次结构是什么? CollectionView 是在 ScrollView 内吗?或其他有自己检测的子视图
-
最好使用视图调试并检查collectionviewCell的contententView之上是否有任何视图。确保您在 mainThread 上重新加载 collectionView
-
@iOSGeek 添加了有问题的视图层次结构屏幕
-
@Pandey_Laxman Didselect 委托函数在我按下单元格 3/4 秒时被调用...
-
@JobinsJohn 在 View Debugging 中捕获模拟器或设备上的运行屏幕,然后检查。
标签: ios swift uicollectionview swift4