Zhao Xiang
Zhao Xiang

Reputation: 1643

How to have UINavigationController use flip animation while push a UIViewController

Now I have four UITableViewControllers.

I need the following effect:

All views (A, B1, B2 and C) should have NavigationBar.

Now I can navigate between A, B1, B2, C. I can also flip to B2 using the following code:

//self is B1
- (IBAction)b2ButtonPressed
{
    B2ViewController* B2 = [[B2ViewController alloc] init];
    B2.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

    [self presentModalViewController:B2 animated:YES];
}

But on B2 the NavigationBar is missing.

I have an app on my iPod touch has such feature. How can I make it myself?

Upvotes: 5

Views: 5063

Answers (2)

user745098
user745098

Reputation:

Can you make use of UIView animations to make the B1 view flip and when the animations is finished, add the B2 view on the parent view ?

I think, this would keep the nav bar as it is.

Upvotes: 2

cxa
cxa

Reputation: 4248

If you show the view controllers by modal presenting, not by navigation controller's push or pop, you should wrap a navigation controller for the view controller in order to show the navigation bar:

- (IBAction)b2ButtonPressed
{
  B2ViewController* B2 = [[B2ViewController alloc] init];
  UINavigationController *B2Nav = [[UINavigationController alloc] initWithRootViewController:B2];   
  B2Nav.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
  [self presentModalViewController:B2Nav animated:YES];
  [B2 release];
  [B2Nav release];
}

And don't forget to setup left or right bar button item for navigation bar in your B2ViewController.

Upvotes: 5

Related Questions