【问题标题】:Reloading TableView from CollectionViewCell从 CollectionViewCell 重新加载 TableView
【发布时间】:2016-12-21 18:14:09
【问题描述】:

有谁知道如何重新加载 CollectionViewCustomCell? 内部的 TableView 我有一个 IBOutletTable 并且访问 Table 的唯一方法是在内部 cellForItemAtIndexPath我可以访问我的CollectionViewCustomCell 并通过该方法访问Table

cell.tableViewInsideOfCollectionViewCell.reloadData()

但这仅适用于第一次加载,当我更改 CollectionView 源时,它不会重新加载 TableView

如果您需要更多信息,请询问!

提前致谢!

【问题讨论】:

    标签: swift uitableview uicollectionview uicollectionviewcell reloaddata


    【解决方案1】:

    您可以使用collectionView.cellForItem(at: IndexPath) 方法获取单元格。然后将其转换为包含 tableView 的单元格类型。现在您可以访问该单元格属性并可以重新加载 tableView。

    guard let cell = collectionView.cellForItem(at: IndexPath(row: , section: )) as? CustomCellWithTableView else { return }
    cell.tableView.reloadData()
    

    【讨论】:

    • 非常感谢! @贾斯汀M
    猜你喜欢
    • 1970-01-01
    • 2011-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多