如何在collectionView中调用tableView的didDeselectRowAt
Posted
技术标签:
【中文标题】如何在collectionView中调用tableView的didDeselectRowAt【英文标题】:How to call didDeselectRowAt of tableView in a collectionView 【发布时间】:2017-07-12 07:50:33 【问题描述】:我有一个 collectionView 和一个 tableView。当我在 tableView 上切换一个单元格时,它会将该单元格添加/删除到 collectionView。当我单击它时,从 collectionView 中删除一个单元格。单击collectionView的单元格时,我想调用tableView的didDeselctRowAt。
tableView(tableView, didDeselectRowAt: indexPath) // in collectionView
上述方法有效。但是,当我再次单击 tableView 单元格时,此方法再次调用。有没有类似的财产
cell.isDidDeselect = true // cell of tableView
为了防止再次调用它。
【问题讨论】:
【参考方案1】:从问题到答案的移动解决方案:
更新和回答
我找到了答案:
使用
tableView.deselectRow(at: indexPath, animated: true) tableView.delegate?.tableView!(tableView, didDeselectRowAt: indexPath)
而不是
tableView(tableView, didDeselectRowAt: indexPath)
【讨论】:
以上是关于如何在collectionView中调用tableView的didDeselectRowAt的主要内容,如果未能解决你的问题,请参考以下文章