I have a UIView that contains a subview called menuView managed by a MenuViewController.
I wrote that code :
- (void) viewDidLoad
{
[self.menuView setFrame:CGRectOffset(self.menuView.frame, 0.0, self.menuView.frame.size.height)];
[super viewDidLoad];
}
- (void) viewDidAppear:(BOOL)animated
{
[UIView beginAnimations:@"SomeAnimation" context:nil];
[UIView setAnimationDuration:2.0];
[UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.menuView cache:YES];
[self.menuView setFrame:CGRectOffset(self.menuView.frame, 0.0, -self.menuView.frame.size.height)];
[UIView commitAnimations];
[super viewDidAppear:animated]; // tried at begining too
}
But when loaded, no animation is visible… I also tried with viewWillAppear with no change.
it is called outside MenuViewController with :
- (IBAction) showMenu
{
MenuViewController* menuController = [[MenuViewController alloc] initWithNibName:@"Menu" bundle:nil];];
[self.view addSubview:menuController.view];
// [menuController release]; for try
}
What’s the problem ?
P.S. : What I want to do is when the view is displayed, some part of that view (the menuView) move. That view (partially transparent) is intended to cover a superview that is owned by another ViewController.
Are you calling the viewDidAppear method from your view controller? Some controllers, such as the UINavigationController, will take care of that, but if you’re using a custom controller, you’ll need to call it. Typically, you would call viewWillAppear, then add the view, the call viewDidAppear.
So your code block would be: