我有一個示例代碼,但每段的行不會顯示,因爲numberOfRowsInSection
不再存在於SWIFT 3
中。如何在SWIFT 3中執行對UITableView的剖面和單元格的動態創建
我目前擁有的FF代碼:
let section = ["pizza", "deep dish pizza", "calzone"]
let items = [["Margarita", "BBQ Chicken", "Pepperoni"], ["sausage", "meat lovers", "veggie lovers"], ["sausage", "chicken pesto", "prawns", "mushrooms"]]
override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
return self.section[section]
}
override func numberOfSections(in tableView: UITableView) -> Int {
return self.section.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "tableCell", for: indexPath)
// Configure the cell...
cell.textLabel?.text = self.items[indexPath.section][indexPath.row]
return cell
}
結果:
有人可以顯示更新swift 3
正確的代碼?謝謝!
你沒有它你的代碼示例中,你有沒有實施'numberOfRowsInSection'? – Wes
我做過了,但是xcode突出顯示爲紅色,表示它是未知的,但在tableView工作之前添加_。<。謝謝! – ReversedcigoL