Вот как выглядит TableViewController:
Код: Выделить всё
class MyTableViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
...
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "id", for: indexPath) as! MyTableViewCell
return cell
}
}
Код: Выделить всё
class MyTableViewCell: UITableViewCell {
lazy var button: UIButton = {
let button = UIButton()
button.translatesAutoresizingMaskIntoConstraints = false
return button
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
......
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
......
}
Подробнее здесь: https://stackoverflow.com/questions/786 ... leviewcell