サンプルコードがありますが、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
については
下記参照あなたのコードサンプルでそれを持っていない、あなたは 'numberOfRowsInSection'を実装したのですか? – Wes
私はしましたが、xcodeはそれが不明だと言って赤く強調表示しましたが、tableViewが動作する前に_を追加しました。 – ReversedcigoL