I have one UIViewController with my logo centered and UITableView with alpha 0.
In viewDidAppear: I have this:
[UIView animateWithDuration:0.6 delay:0.0 options:UIViewAnimationCurveEaseInOut animations:^{
[self.logo setFrame:CGRectMake(0.0f, self.view.frame.size.height - 194.0f, 320.0f, 194.0f)];
} completion:^(BOOL finished) {
[self.table setFrame:CGRectMake(0.0f, 0.0f, 320.0f, self.view.frame.size.height - 194.0f)];
[UIView animateWithDuration:0.4 delay:0.0 options:UIViewAnimationCurveEaseInOut animations:^{
[self.table setAlpha:1.0];
} completion:^(BOOL finished) {
return;
}];
return;
}];
Ok, the animation is what I want.
But when I call presentModalViewController: to show next view, UIImageView back to center of screen and UITableView back the the height before.
How do I stay with the same size and position after finishing the animation even change the view?
Thanks.
I’m assuming you set your original frames in
viewDidLoadthis is fine unless the modal clears your system memory. Views are cached as long as they can. So if you modal uses enough memory to reset it,viewDidLoadgets called again resetting your view.A quick and easy way to deal with this is to set the values you want in the
dismissViewController:animated:method if you’re using it, or a delegate method for the modal.If you don’t have either of those you’ll need to do some checking somehow if this is the first load. This isn’t a clean way to deal with it though. If you show some more code we may be able to work out a better solution.