Я пытаюсь создать табличное представление в представлении контейнера, чтобы я мог анимировать его, в отличие от обычного UITableViewController.
В раскадровке создан UIViewController с UIView в качестве «контейнера вида». Внутри containerView находится tableView. ИДК, почему он продолжает давать мне ноль.
class SearchViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
tableView.dataSource = self
tableView.delegate = self
tableView.register(SearchViewCell.self, forCellReuseIdentifier: "SearchResult")
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "SearchResult", for: indexPath) as! SearchViewCell
cell.addressLabel.text = "Hello"
cell.subtitleLabel.text = "There"
return cell
}
}
SearchViewCell
class SearchViewCell: UITableViewCell {
@IBOutlet weak var addressLabel: UILabel!
@IBOutlet weak var subtitleLabel: UILabel!
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
}
}