tags:

views:

170

answers:

2

I am using a tab bar with a button that calls the current view and does a flip animation to reload it. Once it reloads it performs some operations that alter the view slightly from the last time it was visible.

While the view is flipping, you are able to see the previous view below it.

When I use:

[menuView removeFromSuperview];

the view flips the superview is black underneath like I want but the:

-(void)viewDidLoad

does not fire. My new flipped view is unchanged.

What I want is for the back to be black while the view is flipping and the viewDidLoad to fire.

Any help?

A: 

I am surprised viewDidLoad was called more than once either way. Have you tried putting the code to update the view in viewWillAppear instead?

gerry3
I used viewWillAppear and viewDidAppear and the view comes up black.
Iron Mike
A: 
-(void)viewDidLoad{
  //do some stuff and update the view
}

--(void)tabBar:(UITabBar *)Controls didSelectItem:(UITabBarItem *)item {
  switch (item.tag) {
 case 0:
        XxxxXxxx *viewController = [[XxxxXxxx alloc] initWithNibName:@"xxxxxx" bundle:nil];
  self.xxxxXxxx = viewController;
  [viewController release];

  UIView *menuView = xxxxXxxx.view;

  [UIView beginAnimations:nil context:NULL];
  [UIView setAnimationDuration:1];
  [UIView setAnimationTransition:(self.view ? UIViewAnimationTransitionFlipFromRight : UIViewAnimationTransitionFlipFromRight ) forView:self.view cache:YES];

  [viewController viewWillAppear:YES];
  [self.view addSubview:menuView];
  [viewController viewDidAppear:YES];

  [UIView commitAnimations]; 
  //[menuView removeFromSuperview];
  break;
   }
}

When [menuView removeFromSuperview]; is commented out the viewDidAppear works fine everytime but the old view is behind it.

When [menuView removeFromSuperview]; is NOT commented out the viewDidAppear doesn't work but the old view is gone!

Iron Mike
BTW, initWithNibName:@"xxxxxx" is the current view
Iron Mike