【问题标题】:nested push animation can result in corrupted navigation bar multiple warning嵌套推送动画可能导致导航栏损坏多次警告
【发布时间】:2012-08-05 00:39:50
【问题描述】:

我是 ios 应用程序开发的新手,遇到多个警告问题。

我有一个加载表格视图的导航控制器。 从该表视图中,单击一个单元格会推送一个新的 VC(基本上是单元格的详细信息)。 而在那个“detailView”上,当某个按钮被按下时,另一个VC被按下。

我使用以下代码推送最后一个 VC:

- (IBAction)toMoreDetail:(id)sender 
{
    [self performSegueWithIdentifier:@"toMoreDetail" sender:self];
}

当我这样做时,会弹出 2 个警告:

2012-08-05 02:25:41.842 appName[2145:f803] nested push animation can result in corrupted navigation bar
2012-08-05 02:25:42.197 appName[2145:f803] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.

到目前为止,我没有找到任何好的答案。 也许任何人都可以帮助我解决这个问题。

谢谢:)

编辑:这是另一个 segue 的代码:

从TableList到detail的VC(segue从prototype cell开始,到detail vc):

- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"toDetailEvent"])
    {
        NSInteger selectedIndex = [[self.tableView indexPathForSelectedRow] row];
        DetailEvent* detailEvent = [segue destinationViewController];
        detailEvent.eventToDisplay = [listEvents objectAtIndex:selectedIndex];
    }
} 

【问题讨论】:

  • 如果您将prepareForSegue 的代码发布为两个segues,这可能会有所帮助。
  • 我用其他segue的代码编辑了帖子
  • 我也发生了同样的事情,我的来自一个按钮,我正在使用故事板。似乎调用了两个视图控制器,但我只有一个查看链接。

标签: ios xcode uinavigationcontroller


【解决方案1】:

我的猜测是您的按钮与 segue 相关联,因此当您在其上添加 IBAction 时,您会触发 segue 两次。

如果您转到 Storyboard 并单击 segue,您应该能够看到它的起点和终点。它的起源是整个视图控制器还是按钮?如果源是整个视图控制器,您只需要手动performSegue。您可以尝试将您的 [self performSegueWithIdentifier:@"toMoreDetail" sender:self]; 内容注释掉,看看它是否有效?

【讨论】:

    【解决方案2】:

    似乎如果您使用故事板并将您的 segue 从源 vc 连接到目标 vc 并使用 didSelectRow 调用 segue,则您不能为 segue 选择留下 else 语句: 这有效:

    if ((indexPath.row == 0 && indexPath.section == 0)) {
        [self performSegueWithIdentifier:@"simpleLines" sender:self];
    }
    if ((indexPath.row == 0 && indexPath.section == 5)) {
        [self openAppStore];
    }
    if (indexPath.section == 4)  {
        [self performSegueWithIdentifier:@"pushSettingsVC" sender:self];
    }
    

    这不起作用:

    if ((indexPath.row == 0 && indexPath.section == 0)) {
        [self performSegueWithIdentifier:@"simpleLines" sender:self];
    }
    if ((indexPath.row == 0 && indexPath.section == 5)) {
        [self openAppStore];
    }
    else  {
        [self performSegueWithIdentifier:@"pushSettingsVC" sender:self];
    }
    

    使用导航控制器时,您会得到一个奇怪的双推。每次我开始一个项目时我都会这样做,但总是忘记它为什么会发生。下次我

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-28
      • 1970-01-01
      • 2011-09-19
      • 2013-11-22
      相关资源
      最近更新 更多