【发布时间】:2016-12-12 13:02:56
【问题描述】:
我有一个有趣的问题。因为我是 Swift 新手。
我在 TableView 上创建并使用 Storyboard 添加了CUSTOM CELL。现在我想添加另一个 CUSTOM CELL 当点击第一个 CUSTOM CELL UIButton。
第二个自定义单元是使用 XIB 创建的。现在,当我在 didload 中注册第二个单元格时,我看到空白表格视图,因为第二个自定义单元格为空白。
我使用了以下代码:
用于注册第二个单元格
self.tableView.registerNib(UINib(nibName: "customCell", bundle: nil), forCellReuseIdentifier: "customCell")
索引行的单元格
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! Cell
cell.nameLbl.text = "Hello hello Hello"
let Customcell = tableView.dequeueReusableCellWithIdentifier("customCell", forIndexPath: indexPath) as! customCell
if self.Selected == "YES" {
if self.selectedValue == indexPath.row {
return Customcell
}
return cell
}
else{
return cell
}
}
这里的 Cell 对象用于 Storyboard Cell,Customcell 用于 XIB Second custom cell。
请建议我如何做到这一点。
【问题讨论】:
标签: ios swift uitableview