I've designed a tableView
and tableViewCell
programatically, without the use of storyboards. My viewDidLoad()
in the ViewController
looks something like this:
tableView.delegate = self
tableView.dataSource = self
tableView.register(TicketsTableViewCell.self,forCellReuseIdentifier:cellReuseIdentifier)
tableView = UITableView(frame: UIScreen.main.bounds, style: .plain)
self.view.addSubview(tableView)
And my tableViewCell
looks something like this:
class TicketsTableViewCell: UITableViewCell {
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
//Other View related stuff
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func layoutSubviews() {
super.layoutSubviews()
}
The thing is, when I run it, I'm able to see the tableView
, but not the cells. Furthermore, when I add a breakpoint at cellForRowAt:
, it does not get called. What is that I'm doing wrong? Is there something wrong I'm doing with the reuse identifier?
Thanks in advance.