'UITableView' failed to obtain a cell from its dataSource

前端 未结 3 521
旧时难觅i
旧时难觅i 2021-01-23 20:10

I updated Xcode and since then I\'v problems with my dataBase. code:

override func numberOfSections(in tableView: UITableView) -> Int {
    // return the numb         


        
3条回答
  •  时光取名叫无心
    2021-01-23 20:42

    Add this to your viewDidLoad method:

    tableView.register(LeadsTableViewCell.self, forCellReuseIdentifier: "Cell")
    

    This is assuming you don't have a prototype cell in the tableView in your storyboard. If you do have a prototype cell, ensure the Reuse Identifier is "Cell" and the custom class of the cell is LeadsTableViewCell; then there'll be no need to register the cell.

    UPDATE

    I just noticed your method name is wrong, it should be:

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    
        let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! LeadsTableViewCell
    
        // Configure the cell...
        cell.user_name_label.text = leadItems[indexPath.row].user_name
        cell.school_name_label.text = leadItems[indexPath.row].school_name
    
        return cell
    }
    

提交回复
热议问题