2017-12-18 379 views
0

enter image description here在迅速4

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 
    } 

添加的TableView到AlertController我具有低于错误。

“无法离队与标识符memoCell细胞 - 必须注册标识的笔尖或类或故事板连接原型细胞”

我不知道为什么。 我设置类的故事板没有错误,也可以设置标识正确

我的代码是在github https://github.com/kotran88/iostableviewTest

请帮我得到这个权利

+0

你尝试'init'了'UITableViewCell'用'style'和'reuseIdentifier',有一个初始化已经存在,只是覆盖它并且称'超级'。 – MEnnabah

+1

这个问题的标题与你在问题中提出的问题无关。这很混乱。 – rmaddy

+1

请不要截图你的代码。把它作为你问题的一部分,就像你对第二部分做的一样。 – the4kman

回答

1

你必须注册您的厦门国际银行/笔尖在ViewController viewDidLoad方法

let yourCustomNib = UINib(nibName: "MemoCellTableViewCell", bundle: nil) 
    self.tableView.register(yourCustomNib, forCellReuseIdentifier: "memoCell")