【问题标题】:UINavigation to Show the third viewUINavigation 显示第三个视图
【发布时间】:2012-06-14 17:29:52
【问题描述】:

我有一个应用程序,它利用情节提要中的 UINavigation 控制器通过两个 UITableViews 进入详细信息视图。我想跳过第二个表视图并直接进入详细视图。当用户点击“返回”时,他们应该会看到第二个表格视图。

如果我使用

    [self.navigationController pushViewController:secView animated:NO];
    [self.navigationController pushViewController:thirdView animated:YES];

应用程序出错了,我得到了

nested push animation can result in corrupted navigation bar
2012-06-11 15:02:23.695 App[3853:f803] Finishing up a navigation transition in an      unexpected state. Navigation Bar subview tree might get corrupted.

我试过了

    [self navigationController].viewControllers = [NSArray arrayWithObjects: dest, detView, nil];
    [[self navigationController] popToViewController:detView animated:YES];

这个工作正常,但我无法回到第一个视图。后退按钮不见了。

我想请一些指点。

【问题讨论】:

标签: iphone ios uinavigationcontroller


【解决方案1】:

好吧,想了想,我想出了一个不同的答案:

NSMutableArray *viewControllers = [self.navigationController.viewControllers mutableCopy];
[viewControllers addObject:secView];
[viewControllers addObject:thirdView];
[self.navigationController setViewControllers:viewControllers animated:YES];
[viewControllers release];

【讨论】:

  • 这只是给出了不支持多次推送同一个视图控制器实例的相同错误
  • 抱歉,我的观点有点不同:我没有使用动画。我发布了一个更好的答案。我认为这是对视图控制器堆栈进行复杂更改的预期方式。
  • 我最终要做的是将 segue 直接指向第三个视图,然后我将(仅)第二个视图添加到上面的 viewControllers 中。现在工作。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多