Rodrigo Ruiz
Rodrigo Ruiz

Reputation: 4355

UIView.animateWithDuration in viewDidAppear happens instantly

Easy to reproduce:

"finished" is logged instantly when I'd expect it to be logged 10 seconds after launch (5 from the animation duration + 5 from the delay).

How do I fix this?

The original problem I'm trying to solve is to presentViewController (with animated: false) before viewDidAppear, so that I can show the user a LoginViewControllerbefore the view for the controller in the back appears. But turns out that I can't call presentViewController in viewDidLoad or viewWillAppear.

So my workaround would be to set the LoginViewController's view's alpha to 0 and animate it to 1 (I know, it is a different effect, but it's better than calling presentViewController in viewDidAppear causing have the main controller to show and after a millisecond (not literally) have the LoginViewController's view appear).

Upvotes: 1

Views: 317

Answers (0)

Related Questions