Xcode error: 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
用纯代码写tableview出现以上错误,错误是以下代码触发的。刚开始虽然知道是indentifier的问题,但不知道怎么解决。
let CellIdentifier = "CellIdentifier"
let cell:CustomTableViewCell! = tableView.dequeueReusableCell(withIdentifier: CellIdentifier, for: indexPath) as? CustomTableViewCell
后面百度了,原来我那个CellIdentifier还没注册。解决问题途径是在初始化tableview的地方加上以下代码:
table.register(UITableViewCell.self ,forCellReuseIdentifier: "CellIdentifier")
本文介绍了一个关于使用Swift和Xcode编写TableView时遇到的错误——无法从队列中获取标识符为'CellIdentifier'的单元格。文章详细解释了错误的原因,并提供了具体的解决方案,即在TableView初始化时注册单元格标识符。
5378

被折叠的 条评论
为什么被折叠?



