1. // 若是要tableview 自动设置行高 须要在建立tablev时添加以下两个属性: 自动适应高度,和预估行高swift
tableV.rowHeight = UITableViewAutomaticDimensionide
tableV.estimatedRowHeight = 44ui
2. // 有没有遇到过,导航+UITableView,在push,back回来以后,当前cell仍然是选中的状态。
固然,解决办法简单,添加一句spa
1 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 2 { 3 [tableView deselectRowAtIndexPath:indexPath animated:YES]; 4 // 不加此句时,在二级栏目点击返回时,此行会由选中状态慢慢变成非选中状态。 5 // 加上此句,返回时直接就是非选中状态。 6 }
3. // 自定义cellcode
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = TSSystemMessagesCell.cellFor(tableView) } static let cellId = "systemMessages" class func cellFor (tableView:UITableView) -> TSSystemMessagesCell{ var cell = tableView.dequeueReusableCellWithIdentifier(self.cellId) as? TSSystemMessagesCell if cell == nil { cell = TSSystemMessagesCell.init(style: .Default, reuseIdentifier: cellId) } return cell! } override init(style: UITableViewCellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) creatUI() self.backgroundColor = UIColor.init(redValue: 245, greenValue: 245, blueValue: 245) } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") }