forkingdog / UITableView-FDTemplateLayoutCell

Template auto layout cell for automatically UITableViewCell height calculating
MIT License
9.93k stars 2.01k forks source link

明明已经注册了reuse identifier还报错 #353

Open RichDaddyCashMany opened 6 years ago

RichDaddyCashMany commented 6 years ago

NSAssert(templateCell != nil, @"Cell must be registered to table view for identifier - %@", identifier);

iostalks commented 6 years ago

有可能是你注册 cell 的姿势不对。

在 cellForRow 方法里面,检查一下不带 indexPath 的 dequeueReusableCell(withIdentifier:) 方法,是否会返回 nil,如果会的话就是没有注册 reuse identifier。

要么在 viewDidLoad 里面用 tableView.register(MyCell.self, forCellReuseIdentifier: "cell")注册,要么在 storyboard 里面填上 reuse identifier。

ShaneFang commented 6 years ago

出现同样的问题,iOS 11真机

Batxent commented 6 years ago

出现同样的问题, cell的注册在ViewDidLoad中进行

ShaneFang commented 6 years ago

@Batxent 试试不要在registercell之前设置tableview的header或者footer

Batxent commented 6 years ago

@ShaneFang 是的,这样确实就不会报错。但是问题的原因目前不详。