Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.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
Swift 调用CellForRowatineXpath后上载TableView_Swift_Parsing_Tableview_For In Loop - Fatal编程技术网

Swift 调用CellForRowatineXpath后上载TableView

Swift 调用CellForRowatineXpath后上载TableView,swift,parsing,tableview,for-in-loop,Swift,Parsing,Tableview,For In Loop,这肯定不是最好的方法,所以如果你有更好的答案,请我愿意接受建议。。。我是一个新的程序员。我有一个instagram类型的个人资料,每个单元格显示3个按钮。。。imageView1、imageView2和imageView3。它们是按钮,因为当用户单击它们时,我想转到另一个VC来显示图像。所以,我的问题是,我想用picPostArray中的图像填充按钮。我在CellForRowAtIndexPath中运行for in循环。我认为它可以工作,但是我不知道如何刷新tableview以显示新数据。我的其

这肯定不是最好的方法,所以如果你有更好的答案,请我愿意接受建议。。。我是一个新的程序员。我有一个instagram类型的个人资料,每个单元格显示3个按钮。。。imageView1、imageView2和imageView3。它们是按钮,因为当用户单击它们时,我想转到另一个VC来显示图像。所以,我的问题是,我想用picPostArray中的图像填充按钮。我在CellForRowAtIndexPath中运行for in循环。我认为它可以工作,但是我不知道如何刷新tableview以显示新数据。我的其他配置文件数据在ViewDid出现后全部刷新,并且工作正常。谢谢:)

cellforrowatinexpath:

对于0中的i..如果要重新加载数据,必须使用
tableView.relaodData()

顺便说一句,如果您的阵列中始终有3个图像,那么您可以执行以下操作:

if picPostArray.count == 3 {
      cell.imageView1.imageView!.image = picPostArray[0]
      cell.imageView2.imageView!.image = picPostArray[1]
      cell.imageView3.imageView!.image = picPostArray[2]
    }
否则,如果你的数组是动态的,但是是3的倍数

let row = indexPath.row 
 cell.imageView1.imageView!.image = picPostArray[row * 3 + 0]
 cell.imageView2.imageView!.image = picPostArray[row * 3 + 1]
 cell.imageView3.imageView!.image = picPostArray[row * 3 + 2]
let row = indexPath.row 
 cell.imageView1.imageView!.image = picPostArray[row * 3 + 0]
 cell.imageView2.imageView!.image = picPostArray[row * 3 + 1]
 cell.imageView3.imageView!.image = picPostArray[row * 3 + 2]