0
所以我创建了2个自定义单元格的表格视图。多个TableView自定义单元格
我想输入数据到第三个单元格,但即时通讯有一个问题,当返回多少单元格&也使我的标题数组从我的第三个单元格开始。
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 3
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var row = indexPath.row
if(row == sliderIndex){
var cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! Row
return cell
}else if (row == instagramIndex) {
var cell2 = tableView.dequeueReusableCell(withIdentifier: "instgramCell", for: indexPath) as! Insta
return cell2
} else {
var cell3 = tableView.dequeueReusableCell(withIdentifier: "blogCell", for: indexPath) as! blogCell
if (row == 3) {
cell3.blogTitle.text = titleArray[0]
}
return cell3
}
我猜'sliderIndex = 0'和'instagramIndex = 1'?然后,'numberOfRows'等于'titleArray.count + 2',在你的'else'情况下,只需要'cell3.blogTitle.text = titleArray [row-3]'或类似的东西(可能是+ 1或-1。 – Larme