I am showing a login screen with an error, like:
_loginViewController.error = error;
[_navigationController presentModalController: _loginViewController
animated: YES];
In LoginViewController, I want to slide the error message onto the screen like this:
- (void)showErrorAnimated: (BOOL)animated;
{
_errorLabel.text = [_error localizedDescription];
[UIView beginAnimations: @"showError"
context: NULL];
CGRect frame = [_errorView frame];
frame.origin.y = 0; // starts at -frame.size.height
[_errorView setFrame: frame];
[UIView commitAnimations];
}
But I don't know how to call this to match the timing of the view controller finishing it's slide to the top of the screen begun by presentModalController:animated:
.
How can I get this timing working?
You should use the viewDidAppear
method of your controller, which will be called the time the view is displayed.
Just be careful with viewDidAppear
because it is called whenever your view is shown. This means that if your controller presents a modal controller and then it is dismissed, the viewWillAppear
and viewDidAppear
methods will be called again.