Reputation: 4355
Easy to reproduce:
copy this code to your view controller that is being launched at start
class ViewController: UIViewController {
override func viewDidAppear(animated: Bool) {
UIView.animateWithDuration(5,
delay: 5,
options: UIViewAnimationOptions.CurveEaseInOut,
animations: {
}, completion: { finished in
print("finished")
}
)
}
}
"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 LoginViewController
before 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