您的位置:首页 > 产品设计 > UI/UE

Xcode error: unable to dequeue a cell with identifier cell

2017-08-11 13:46 1471 查看
 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")
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  xcode ios swift
相关文章推荐