第一次加载表格 View 时看起来不错,但问题是滚动表格 View 或重新加载表格 View 然后 lineView
位置发生变化。
func drowLine(_ cell: UITableViewCell)->UIView{
let lineView = UIView(frame: CGRect(x: 20, y: cell.contentView.frame.size.height - 1.0, width: cell.contentView.frame.size.width - 40 , height: 1))
lineView.backgroundColor = UIColor(red: 56/255, green: 66/255, blue: 72/255, alpha: 0.149)
return lineView
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: titleDisclosureIndicatorID, for: indexPath) as! TitleDisclosureIndicatorCell
//......
cell.contentView.addSubview(drowLine(cell))
return cell
}
class TitleDisclosureIndicatorCell: BaseTableViewCell {
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: .value1, reuseIdentifier: reuseIdentifier)
}
//.....
}
初始加载 TableView :
滚动并重新加载 tableview 行位置后更改一些行:
最佳答案
单元格正在被重复使用,所以我猜您一直在多次添加该行。
您应该以不同的方式处理此问题并使用 RegistrationFormCell
的子类。将该行添加到您的 Storyboard 文件中,您将不会再遇到这个问题。
关于ios - 滚动或重新加载表格 View 后查看位置变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46951710/