Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpectedly found nil while implicitly unwrapping an Optional value #41

Closed
berkakkerman opened this issue Dec 29, 2020 · 2 comments
Closed

Comments

@berkakkerman
Copy link

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
Copy link

piechart commented Jan 1, 2021

Hi @berkakkerman

You need to specify the actual animation to use (e. g. fade) like this

myButton.rx.animated.fade(duration: 0.2).isHidden

@berkakkerman
Copy link
Author

Works like a charm. Thank you. @piechart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants