2017-12-18 215 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")