【发布时间】:2018-09-06 18:44:05
【问题描述】:
我使用的是 Xcode 10.0 beta 6,所以这可能只是一个错误。
我遇到了一个问题,将新的UIView-instance 分配给属性似乎对该属性没有任何影响。
所述属性是leadingView in ViewTextFieldCell:
class ViewTextFieldCell: UITableViewCell {
// ...
var leadingView = UIView()
// ...
}
当通过以下方式修改单元格实例时...
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = ViewTextFieldCell(style: .default, reuseIdentifier: "TestCell")
cell.leadingView.backgroundColor = .blue
let otherView = UIView()
otherView.backgroundColor = .green
cell.leadingView = otherView
return cell
}
...唯一保留的更改是将背景颜色设置为蓝色。otherView的赋值好像没有效果。
这怎么可能?
【问题讨论】:
标签: swift uitableview uiview