override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let row=animals[indexPath.row]
let cellIdentifier = "memoCell"
var cell=tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as! MemoCellTableViewCell
if cell == nil {
print("cell is nill")
cell = MemoCellTableViewCell(style: .default, reuseIdentifier: cellIdentifier)
}
cell.name?.text="aaa"
cell.address?.text="haha"
return cell
}
我有以下错误。
'无法使具有标识符 memoCell 的单元格出队 - 必须为该标识符注册一个 nib 或一个类,或者在 Storyboard中连接一个原型(prototype)单元格'
我不知道为什么。 我在 Storyboard上设置了没有错误的类,并且还正确设置了标识符
我的代码在github上 https://github.com/kotran88/iostableviewTest
请帮我解决这个问题
最佳答案
你必须在 ViewController
viewDidLoad 方法中注册你的 xib/nib
let yourCustomNib = UINib(nibName: "MemoCellTableViewCell", bundle: nil)
self.tableView.register(yourCustomNib, forCellReuseIdentifier: "memoCell")
关于swift - 在 swift 4 中将 TableView 添加到 AlertController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47870552/