How to write height for row in RxSwift?
Other answers are outdated. Here's Swift 4/5 version with RxSwift in 2019.
Firstly set up delegate, typically in viewDidLoad
:
tableView
.rx.setDelegate(self)
.disposed(by: disposeBag)
Then of course, write your delegate method(s) somewhere:
extension HostListViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 64
}
}
If you're binding data to a tableView with RxSwift and want to control row/section height, set your UITableViewDelegate like this:
tableView.rx.setDelegate(self).disposed(by: disposeBag)
and now your func tableView(UITableView, heightForRowAt: IndexPath) -> CGFloat
will get called.