Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/117.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 再次显示viewcontroller时在uitableviewcell上渲染视图_Ios_Swift_Uitableview - Fatal编程技术网

Ios 再次显示viewcontroller时在uitableviewcell上渲染视图

Ios 再次显示viewcontroller时在uitableviewcell上渲染视图,ios,swift,uitableview,Ios,Swift,Uitableview,以下是我的cellForRowAtIndexPath方法: func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let documentPartCell = tableView.dequeueReusableCellWithIdentifier("documentPartCell", forIndexPath:

以下是我的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上的视图

Ex) 期望值:更改前->3/5。更改后->4/5

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


进度标签文本不会更改。

因为您使用的是多个视图控制器,所以我会将与进度关联的变量设置为全局变量(在类之前定义它们)。这将在整个项目中准确地更新它。(这可能不是最佳做法,但它会完成工作)

只需将
yourTableView.reloadData()
放在
viewwillbeen()
中,而不是
viewDidLoad()

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


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

从VC2返回VC1后,其中是重新加载特定单元格的代码,您必须通过委托或通知重新加载它。。。或者在ViewDidAspect()中编写重新加载代码。我已经完成了。重新加载数据解决了这个问题。非常感谢。