gpt4 book ai didi

ios - 将父 ViewController 值发送到 UICollectionViewCell 单元格

转载 作者:行者123 更新时间:2023-11-30 10:57:11 24 4
gpt4 key购买 nike

我遇到以下情况,想知道如何解决将父 UIViewController 值发送到 UICollectionView 单元格的问题。

1) 父 UIViewController 渲染 UICollectionView

2) UICollectionViewCell 动态生成 UILabel 并附加 (UITapGestureRecognizer) 目标

3) 在 UITapGestureRecognizer 上,它会触发一个操作来告诉父级 UIViewController 呈现一个 Popup UIViewController

4)弹出ViewController有一个UITable,其中有几个选项可供选择

5) 选择后,Popup ViewController 被关闭

我可以获得该值,但如何将值从父 UIViewController 传递回 UICollectionViewCell 单元格?

最佳答案

您需要像这样访问您的单元格:

if let cell = collectionView.cellForItem(at: indexPath) as? yourCollectionViewCell { 
cell.yourValue = yourNextValue
}

如果您在此之后需要执行任何 UI 更新,则可能需要调用 beginUpdatesendUpdates 方法。

关于ios - 将父 ViewController 值发送到 UICollectionViewCell 单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53831995/

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