Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Fontano

macrumors member
Original poster
Jun 27, 2008
72
0
Okay,

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.

Code:
// 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];
	}
	else
	{
		[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.
 

Fontano

macrumors member
Original poster
Jun 27, 2008
72
0
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.

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

Thanks for the pointer.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.