I have an issue with observing the contentOffset property of UITableView with RxCocoa.
I've tried RxCocoa property:
view.tableView.rx.contentOffset
.mapAt(\.y)
.subscribe(onNext: { print($0) })
And in console I see (0, 0) once and nothing else.
I've tried to replace it with code from RxCocoa:
ControlProperty(
values: BehaviorSubject<CGPoint>(value: RxScrollViewDelegateProxy.proxy(for: view.tableView).scrollView?.contentOffset ?? CGPoint.zero),
valueSink: Binder(view.tableView) { scrollView, contentOffset in
scrollView.contentOffset = contentOffset
}
)
.subscribe(onNext: { print("myOffset", $0) })
And got the same result: myOffset (0, 0) once and nothing else.
I've tried to observe other property and haven't got anything:
view.tableView.rx.didScroll
.subscribe(onNext: { print(view.tableView.contentOffset) })
BUT. I've tried to add Observable interval:
Observable<Int>.interval(1, scheduler: MainScheduler.instance)
.subscribe(onNext: { _ in print(view.tableView.contentOffset) })
And each second I've got different points: (0, 0), (0, 38), (0, 64).
I'm using: RxCocoa (5.0.0); RxSwift (5.0.0)