views:

59

answers:

2

Hello

I have 2 views, one login and another home. On clicking the signin button in my login view, on successful login, the user is redirected to the home view. Flip transition is implemented to acheive this. The problem is after the flip has occured, the home view layout is not displayed correctly. The view seems to drag itself above a little, leaving some white space at the bottom of the home view, i.e the home view contents do not fit correctly after the flip. Here is the method which is called on successful login:

-(void)displayHome {
if (loginController == nil) {
 [self loadhome];
}
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES]; 
[homeController viewWillAppear:YES];
[loginController viewWillDisappear:YES];
[loginController.view removeFromSuperview];
[self.view addSubview:homeController.view];
[loginController viewDidDisappear:YES];
[homeController viewDidAppear:YES];
[UIView commitAnimations]; }


-(void)loadhome {

HomeController *hm = [[HomeController alloc]initWithNibName:@"Home" bundle:nil];
self.homeController = hm;
[hm release]; }

Any ideas on how to display the view contents correctly?

Thanks

A: 

I don't believe you need to manually call viewWillAppear etc. manually, I believe they are all called automatically. So they're probably being called twice which might cause a display/positioning error?

FWIW, an easier (and I'd argue better) approach is to display the login controller by calling presentModalViewController on homeController, especially if you are inheriting from UINavigationController. None of the Apple-provided nav-based apps do flipping AFAIK.

Neil Mix
Hello Neil Mix, i am not using the navigation controller in this app. The flipping being a client requirement needs to be adhered to in this case. I'll check out with the calling of viewWillAppear method and post back the result.
CodeWriter
Update: Not calling the viewWillAppear does not make any effect on the display of the home view
CodeWriter
A: 

You should consider moving the viewDid{Appear/Disappear} calls into an animationDidStop delegate method as follows:

[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:)];

- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
    [loginController viewDidDisappear:YES];
    [homeController viewDidAppear:YES];
}

I doubt this will fix your problem (unless you are doing some layout in the viewDidAppear method?). But at least the viewDidAppear/viewDidDisappear methods of your View Controllers will be called at the correct time (when the animation is over, instead of when it has just started).

Alan Rogers