gpt4 book ai didi

ios - 用户点击 UICollectionViewCell 时如何获取 UITableView 行

转载 作者:行者123 更新时间:2023-12-01 16:05:07 24 4
gpt4 key购买 nike

应用方案-
Image
正如你从我的 App Scheme 中看到的,我有 UITableView和内部 UITableViewCells我有 UICollectionView .
我现在的问题是如何获得 UITableView用户点击时的行 UICollectionViewCell ?
我试过这个,但这对我不起作用:

    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
collectionView.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: true)

let main = ViewController()
if let tableViewcell = superview?.superview as? ExploreTableViewCell {
let indexPath = main.tableView.indexPath(for: tableViewcell)


print(indexPath)
}
}

最佳答案

对 Subramanian Mariappan 概念的扩展和使用 delegate获取信息的模式 UIViewController关于集合 View 单元格中的选择,请查看您的解决方案 https://github.com/sauvikapple/StackoverflowQ63802523 .
enter image description here

关于ios - 用户点击 UICollectionViewCell 时如何获取 UITableView 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63802523/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com