我正在尝试设置和编写一个问题及其对表格视图的相应答案,每个单元格代表字典和问题中的一个答案。
字典设置如下:
struct Quest {
question: String,
ans1: String,
ans2: String,
ans3: String,
ans4: String,
cor: String
}
该结构可以容纳从 1 个问题 [0] 到 [100] 的任何地方
我试图调用 reloadata() 函数,但这会在每个单元格中加载不同的问题,而我需要先加载问题,然后再加载四个答案。只是不知道如何做到这一点。
这是我的 cellFor 代码:
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCell(withIdentifier: "ItemCell", for: indexPath)
let label1 = cell.viewWithTag(1) as? UILabel
let myView = cell.viewWithTag(3)
let myItem = items[indexPath.row]
print(indexPath.row)
label1?.text = "Question"
return cell
我尝试让它返回单元格,然后在其下方添加代码以加载下一个单元格,但它一直告诉我,一旦我返回其余代码将不会执行,我理解。
任何帮助,将不胜感激。