Flip Animation: Navigation Bar

Discussion in 'iOS Programming' started by Fontano, Oct 9, 2008.

  1. Fontano macrumors member

    Jun 27, 2008

    So I managed to figure out how to FLIP between two views.
    However, now I am running it an unexpected side-effect.

    Originally I was hoping to do the flip in the view that is underneath the navigation bar, and not have it leave the screen. However, that doesn't appear to be case, unless I am just doing it wrong. But I am okay with it flipping the entire screen, if that is the only way it can do it.

    The problem I have though, is when I flip BACK to the main screen, the navigation bar is gone.

    Am I talking to the wrong view as the container? Or how do I have to go and re-add the NavigationControler (and it's bar).

    The NavigationController is defined in the AppDelegate, and this code is in the ViewController for the views.

    // Button Actions
    - (IBAction)flipAction:(id)sender {
    	// Get Container View
    	if ((viewContainer) == FALSE) {
    		viewContainer = [self navigationController].view;
    	// Setup Flip-Animation
    	[UIView beginAnimations:nil context:NULL];
    	[UIView setAnimationDuration:kTransitionDuration];
    	[UIView setAnimationTransition:([viewMainMenu superview] ? UIViewAnimationTransitionFlipFromLeft :  UIViewAnimationTransitionFlipFromRight)
              forView:viewContainer cache:YES];
    	// Execute Flip
    	if ([viewMainMenu superview])
    		[[self navigationController] setNavigationBarHidden:YES animated:YES];
    		[viewMainMenu removeFromSuperview];
    		[viewContainer addSubview:viewSettings];
    		[viewSettings removeFromSuperview]; 
    		[viewContainer addSubview:viewMainMenu];
    	[UIView commitAnimations];
    The line: [[self navigationController] setNavigationBarHidden:YES animated:YES];
    I added in an attempt to fix the issue. Originally without the line, when I flipped back, I would get a "white" block on the bottom of the screen, which was the space of the navigation bar (which was at top, and the view slides up on the return). Once I added that line, that at least eliminated the white bar.
  2. richard.puckett macrumors newbie


    Jul 15, 2008
    Seattle, WA
    Have you checked out The Elements sample app? There's a good implementation of view flipping in there that you could pull out pretty easily.
  3. Fontano thread starter macrumors member

    Jun 27, 2008
    Nope, didn't look at that one.
    I used UIControls Sample as my "inspiration" code sample.

    Thanks for the pointer.

Share This Page