5

现在我有四个UITableViewControllers.

  • 一种
  • B1、B2
  • C

我需要如下效果:</p>

  • 在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];
}

但是在 B2 上,缺少 NavigationBar。

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

4

2 回答 2

5

如果您通过模态呈现而不是导航控制器的推送或弹出来显示视图控制器,则应该为视图控制器包装一个导航控制器以显示导航栏:

- (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];
}

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

于 2011-06-19T13:43:04.533 回答
2

您可以利用UIView animations使 B1 视图翻转并在动画完成后在父视图上添加 B2 视图吗?

我认为,这将使导航栏保持原样。

于 2011-06-19T13:55:34.543 回答