如何让UINavigationController在推送UIViewController时使用翻转动画

Zha*_*ang 5 iphone uiviewcontroller uiviewanimation

现在我有四个UITableViewControllers.

  • 一个
  • B1,B2
  • C

我需要以下效果:

  • 选择A上的项目可以推送到B1
  • 点击B1上的rightBarButtonItem可以水平翻转到B2
  • 点击B2上的rightBarButtonItem可以水平翻转到B1
  • 选择B1或B2上的项目可以推送到C.
  • 可以在B1或B2弹出A

所有视图(A,B1,B2和C)都应该有NavigationBar.

现在我可以在A,B1,B2,C之间导航.我也可以使用以下代码翻到B2:

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

    [self presentModalViewController:B2 animated:YES];
}
Run Code Online (Sandbox Code Playgroud)

但在B2上,NavigationBar缺失了.

我的iPod touch上有一个应用程序有这样的功能.我怎么能自己做?

cxa*_*cxa 5

如果通过模态显示而不是通过导航控制器的push或pop显示视图控制器,则应该为视图控制器包装导航控制器以显示导航栏:

- (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];
}
Run Code Online (Sandbox Code Playgroud)

并且不要忘记在B2ViewController中为导航栏设置左侧或右侧栏按钮项.