У меня есть tabviewcell, и я хочу динамически установить текст метки (подпредставление tableviewcell). Но когда я устанавливаю его, метки высот показывают 0 (не видно на экране). Мой код находится ниже, но когда я устанавливаю текст, он непересчитать высоту. В чем здесь проблема?
protocol EarningsSemisecureViewDelegate : class {
func enterButtonTapped()
}
class EarningsSemisecureViewCell : UITableViewCell {
var noDataText : String? {
didSet(newValue) {
noDataLabel.text = newValue?.localized()
}
}
private var noDataLabel = RadxLabel()
weak var delegate: EarningsSemisecureViewDelegate?
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
customizeView()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
customizeView()
}
private func customizeView() {
self.backgroundColor = UIColor.white
self.contentView.backgroundColor = UIColor.white
selectionStyle = UITableViewCell.SelectionStyle.none
noDataLabel.numberOfLines = 0
noDataLabel.textAlignment = .center
noDataLabel.translatesAutoresizingMaskIntoConstraints = false
self.contentView.addSubview(noDataLabel)
noDataLabel.leading = self.contentView.leading + 10
noDataLabel.trailing = self.contentView.trailing - 10
noDataLabel.top = self.contentView.top + 20
let button = WalletButton()
button.setTitle("login.button.enter".localized(), for: .normal)
button.styleNo = 1
button.translatesAutoresizingMaskIntoConstraints = false
button.addTapGestureRecognizer {[weak self] in
if let semiSecureViewDelegate = self?.delegate {
semiSecureViewDelegate.enterButtonTapped()
}
}
self.contentView.addSubview(button)
button.top = noDataLabel.bottom + 30
button.trailing = self.contentView.trailing - 10
button.leading = self.contentView.leading + 10
}
}
let semisecureViewCell = EarningsSemisecureViewCell()
semisecureViewCell.noDataText = "earnings.not.login.info"
return semisecureViewCell
ячейка возвращается в tableviewdatasource.