How can I change the height of the BottomPopUp in RxSwift

35 Views Asked by At

I use RxSwift in my project After I called an API in Viewmodel and transferred to ViewController, I took the number of data. Then I want to change the Popup height with the number of data. How can I do it?

I try to use a variable to handle it. But it doesn't work

I init a variable to hold the height of the Popup enter image description here

Then I set the height for the Popup

enter image description here

1

There are 1 best solutions below

2
Daniel T. On

Strictly speaking, you have not provided enough code to answer the question, but generally I sure what is happening here is that your code is trying to read the value of heightOfVC before the value has been set by the do(onNext:) statement.

The best solution would likely be to make heightOfVC (and popupHeight) conform to the Observable contract. Ideally, you would do this by making them Observable<CGFloat> but you could also use BehaviorSubject<CGFloat> or any of the other types that follow the contract (implement the ObservableConvertibleType protocol.)