unable to dequeue a cell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard

前端 未结 22 2127
面向向阳花
面向向阳花 2020-12-12 17:33

I am fairly new to coding in general and really new to Xcode (Swift). I understand that I need to register a nib or a class but I don\'t understand \'where or how?\'.

<
22条回答
  •  伪装坚强ぢ
    2020-12-12 18:18

    You can register a class for your UITableViewCell like this:

    With Swift 3+:

    self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
    

    With Swift 2.2:

    self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")
    

    Make sure same identifier "cell" is also copied at your storyboard's UITableViewCell.

    "self" is for getting the class use the class name followed by .self.

提交回复
热议问题