我目前有兩個UITableView
s填充了應用程序的聯繫人。我有一個只是查看他們和編輯/刪除和一個從列表中搜索/選擇聯繫人。但是,當我嘗試使用UITableView
s的相同自定義類單元格時,我得到一個返回的零值。使用相同的自定義單元實現兩個UITableView以便重用
這些是我的兩個cellForRowAtIndexPath
函數。
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = self.tableView.dequeueReusableCellWithIdentifier("SecondCell") as! ContactCell
let item = contacts[indexPath.row]
cell.meetupLabel?.text = item.fullName
return cell
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = self.tableView.dequeueReusableCellWithIdentifier("FirstCell") as! ContactCell
let item = contacts[indexPath.row]
cell.label?.text = item.fullName
return cell
}
您確定在IB中爲您的單元設置了不同的標識符(SecondCell/FirstCell)嗎?我 –