Simple UITableView in Swift - unexpectedly found nil

后端 未结 13 1620
旧巷少年郎
旧巷少年郎 2020-12-06 00:38

Pretty simple code:

func numberOfSectionsInTableView(tableView: UITableView?) -> Int {
    return 1
}

func tableView(tableView:UITableView!, numberOfRows         


        
13条回答
  •  鱼传尺愫
    2020-12-06 01:29

    If you're using storyboard, make sure you don't have this line at the start of your file:

    self.tableView.registerClass(CustomTableViewCell.self, forCellReuseIdentifier: "customCell")
    

    It will overwrite the storyboard and as a result, the outlet links in the storyboard are ignored.

提交回复
热议问题