[ASDisplayNode] setNeedsLayout doesn't work only Texture 2.7
GeekTree0101 opened this issue · 5 comments
similar issue
In my case, I forced setNeedLayout after textNode attributedText value with a few sec delay
Observable.just(NSAttributedString(string: "test")
.delay(2.0, scheduler: MainScheduler.asyncInstance) // a few sec delay
.subscribe(onNext: { [weak self] value in
self?.textNode.attributedText = value // update attributedText (data)
self?.setNeedsLayout() // call setNeedsLayout
}
.disposed(by: disposeBag)
Texture 2.6 is correctly work like this picture
But, I got unwanted UI in Texture 2.7 like this picture
I check frame value from debugger
I found that UITableViewCellContentView frame isn't equal with ASCellNode frame
So, just update ASCellNode frame with UITableViewCellContentView frame on didEnterVisibleState like this code
override func didEnterVisibleState() {
super.didEnterVisibleState()
self.frame = self.view.superview?.frame ?? self.frame
}
I have faced such issue when I was changing collection node layout when rotating device. what I did was I write a custom collection flow layout using ASCollectionLayoutDelegate
to calculate node frame
When Rx subscribe logic moves from initialization to didLoad method. I no longer faced this problem.
When using RxSwift / RxCocoa, it is safe to subscribe from the didLoad method.
close!