0
我想添加自定义tableviewcell分离这样如何添加自定义tableviewcell分隔符?
------------ -----------细胞
---定制sperator ---
------------ -----------细胞
---定制sperator ---
我试过了
添加下面的UIView在细胞和故事板连接
@IBOutlet weak var sperator: UIView!
addcode在cellForRow的cellForRowAtIndexPath
override func tableView(tableView: UITableView, cellForRowAtIndexPathindexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("MainListCell",forIndexPath: indexPath) as! MainTableViewCell let list = List(index: indexPath.row) cell.titleLabel.text = list.title! cell.titleIcon.image = list.icon! cell.detailTitleLabel.text = list.detailtitle! cell.coinCountLabel.text = "X0" cell.addSubview(self.sperator) return cell }
,但是,我可以看到的UIView :(
为什么不为你的分隔符行使用不同的单元格类型 - 相应地增加'numberOfRowsInSection'值,然后返回'cellForRowAtIndexPath'中的正确类型的单元格 – Paulw11
@ Paulw11谢谢!但我可以修复不同的方式。 cell.constent.addSubview(sperator) –
只要确保在重新使用单元格时不再添加分隔符 – Paulw11