gpt4 book ai didi

ios - 当再次显示 viewcontroller 时在 uitableviewcell 上渲染 View

转载 作者:搜寻专家 更新时间:2023-11-01 07:27:28 24 4
gpt4 key购买 nike

这是我的 cellForRowAtIndexPath 方法:

     func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let documentPartCell = tableView.dequeueReusableCellWithIdentifier("documentPartCell", forIndexPath: indexPath) as! DocumentPartCell
documentPartCell.documentPart = documentPart
return documentPartCell
}

这是我的单元格类:

class DocumentPartCell: UITableViewCell {
@IBOutlet weak var documentPartProgress: UILabel!
var allFields: Int
var invalidFields: Int
var documentPart: DocumentPart? {
didSet {
self.documentPartProgress.text = "\(Int(allFields)! - Int(invalidFields)!) / \(allFields)"
}

基本上,documentPartProgress 标签显示文档的进度。我的应用程序的流程是有一个单元格显示 VC1 中的进度。按下单元格时,它会移动到 VC2,您可以进行更改。当您回答问题时,进度会发生变化。当您在 VC2 中按下 back 按钮时,它会返回到 VC1 并且应该更新 documentPartProgress。但事实并非如此。如何在按下 VC2 中的后退按钮时更新 UITableViewCell 上的 View ?

例)预期:更改前 -> 3/5。更改后 -> 4/5

现实:更改前 -> 3/5。更改后 -> 3/5

进度标签文本不会改变。

最佳答案

只需要将 yourTableView.reloadData() 放在 viewWillAppear() 而不是 viewDidLoad()

注意,我想您已经更新了数据源数组。如果您没有更新数据源,则需要使用委托(delegate)或发布通知来更新它。

如果是这种情况,请告诉我,我会更新我的答案以获取更多详细信息。

关于ios - 当再次显示 viewcontroller 时在 uitableviewcell 上渲染 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35034652/

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