Unexpectedly found nil while implicitly unwrapping an Optional value
berkakkerman opened this issue · 2 comments
berkakkerman commented
I am trying to show/hide a view with animation. When I use rx.isHidden it is working. But rx.animated.isHidden occurs crash.
My Code:
someObservable. // Observable<Bool>
.bind(animated: toggleView.rx.animated.isHidden)
.disposed(by: rx.disposeBag)
Crash from Pod:
extension AnimatedSink where Base: UIView {
public var isHidden: Binder<Bool> {
return Binder(self.base) { view, hidden in
self.type.animate(view: view) { // Unexpectedly found nil while implicitly unwrapping an Optional value
view.isHidden = hidden
}
}
}
}
What am I missing?
piechart commented
You need to specify the actual animation to use (e. g. fade) like this
myButton.rx.animated.fade(duration: 0.2).isHidden
berkakkerman commented
Works like a charm. Thank you. @piechart