我的視圖控制器中有一個表視圖控制器。當我給它靜態行數和單元格的行索引方法名稱時,它在表格視圖中對我來說沒有任何顯示。我也重裝表視圖,但它沒有顯示,我不知道爲什麼會這樣,IOS中的表視圖中的數據加載問題
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return messages.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell (style: .subtitle, reuseIdentifier: "cellID")
let message = messages[indexPath.row]
cell.textLabel?.text = message.text
return cell
}
你有沒有設置'代表及datasource'你的tableview –
你需要設置代表。 –