iPhone UINavigation问题-嵌套推送动画可能导致导航栏损坏

iPhone UINavigation问题-嵌套推送动画可能导致导航栏损坏,iphone,ios4,uinavigationcontroller,navigationcontroller,Iphone,Ios4,Uinavigationcontroller,Navigationcontroller,我不断发现以下错误: 2011-04-02 14:55:23.350 AppName[42430:207] nested push animation can result in corrupted navigation bar 2011-04-02 14:55:23.352 AppName[42430:207] nested push animation can result in corrupted navigation bar 2011-04-02 14:55:23.729 AppName

我不断发现以下错误:

2011-04-02 14:55:23.350 AppName[42430:207] nested push animation can result in corrupted navigation bar
2011-04-02 14:55:23.352 AppName[42430:207] nested push animation can result in corrupted navigation bar
2011-04-02 14:55:23.729 AppName[42430:207] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
2011-04-02 14:55:23.729 AppName[42430:207] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
这就是我正在做的。在视图控制器中,当按下某个按钮时,我调用以下命令:

EventsViewController *viewController = [[EventsViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
navController.navigationBar.tintColor = [UIColor blackColor];
[self presentModalViewController:navController animated:YES];
[viewController release];
[navController release];
然后,如果在EventsController中按下某个按钮,我调用:

SingleEventViewController *viewController = [[SingleEventViewController alloc] initWithEvent:[currentEvents objectAtIndex:indexPath.row]];
[self.navigationController pushViewController:viewController animated:YES];
[viewController release];
EventMapView* viewController = [[EventMapView alloc] initWithCoordinates];
[[self navigationController] pushViewController:viewController animated:YES];
[viewController release];
然后,如果在SingleEventViewController中按下某个按钮,我调用:

SingleEventViewController *viewController = [[SingleEventViewController alloc] initWithEvent:[currentEvents objectAtIndex:indexPath.row]];
[self.navigationController pushViewController:viewController animated:YES];
[viewController release];
EventMapView* viewController = [[EventMapView alloc] initWithCoordinates];
[[self navigationController] pushViewController:viewController animated:YES];
[viewController release];

是的,很明显有嵌套的推送动画,但这不是正确的方法吗?我查看了苹果公司的DrillDownSave代码,他们就是这样做的。我用init方法代替viewDidLoad方法有关系吗?

你说用init方法代替viewDidLoad方法是什么意思

如果在旧的推送操作不太可能执行之前推送新的视图控制器,则会出现此类错误。因此,将某些代码放入init并过早地执行操作肯定会导致报告错误

在视图控制器上运行init时,视图尚未加载

1)在按下
UIViewController
之前,您可以尝试将必要的变量作为属性传递,而不是使用带有参数的init方法。最有可能的是,除了init方法之外,您还需要这些参数

另外,在
initWithCoordinates:
方法中,缺少参数。您的自定义init方法可能是问题的一部分


2) 就因为您提到了
viewDidLoad
——此方法用于在加载视图后进行初始化。如果您在代码中创建UIViewController,您应该使用
loadView
来设置子视图。

我已经解决了这个问题。显然,如果您从UITableViewDelegate的-didSelectRowatineXpath方法外部调用-pushViewController,它将不起作用。将调用移到该函数中起作用。奇怪。

我遇到了与您刚才相同的问题/错误消息,正在寻找解决方案,最后出现了此线程,但是,对我来说,我发现解决方案实际上只有一个动画:在执行嵌套推送时是(我将动画:是仅用于最终推送),希望这有所帮助


干杯。

viewdide出现之前调用
pushViewController
是不安全的。

我遇到了同样的问题,因为nib中的一个按钮连接到两个不同的操作。它尝试加载两个视图控制器,从而损坏堆栈。

这已经得到了回答,但我认为这可能会帮助其他人,因为我遇到了相同的错误,但没有使用表视图。我终于解决了这个问题


我有一个现有的按钮,其IBAction调用了pushViewController。我通过复制现有按钮创建了一个新按钮。新按钮还有一个调用pushViewController的操作。当点击新按钮(内部润色)并按下视图控制器时,我得到了这个错误。我删除了新按钮,从头开始创建,将其绑定到现有的插座和操作,错误消失了。

两次意外触发同一个序列 一次在代码中,一次在界面生成器中,但两者同时

我和你们其他人都犯了同样的错误。我唯一的问题是我不小心发射了同一个序列,两次。一次来自interface builder,一次来自我的代码

我的视野很开阔。选择单元格后,interface builder中会触发一个序列。这就是我的问题,我把segue设置为直接触发,点击界面生成器中的单元格本身,然后在我的代码中,我在DidSelectRowatineXpath下设置了触发相同segue的代码。。。就像这样

[self performSegueWithIdentifier:@"MySegue" sender:tableView];
这意味着当由于选择了一行而调用DidSelectRowatineXpath时,它将使用上面的代码行触发segue。然后interface builder也会触发segue,因为它直接连接到interface builder中的单元对象。阻止interface builder直接启动segue。您必须从视图控制器的顶部连接segue,而不是嵌套在单元格本身的内部

因此,如果您遇到这个问题的原因与我相同,也就是说,您两次调用同一个segue,那么您可以通过将连接从单元直接断开到您的segue,并使segue连接起源于IB中表层次结构的顶部,而不是嵌套在单元中来解决这个问题。将segue从视图控制器本身连接到segue。如果操作正确,当您选择segue时,它应该突出显示它来自的整个视图,而不仅仅是单元格

现在苹果的文档在performsguewithidentifier:sender:reference下声明:

应用程序通常不需要直接触发segues。相反,您可以在Interface Builder中配置与视图控制器关联的对象,例如嵌入其视图层次结构中的控件,以触发segue。但是,您可以调用此方法以编程方式触发segue,可能是为了响应脚本资源文件中无法指定的某些操作。例如,您可以从用于处理抖动或加速度计事件的自定义操作处理程序调用它

在我的例子中,我的UITableView有一个搜索按钮,必须确定在搜索结果表存在时调用segue,还是在正常的表视图存在时调用segue。所以我需要直接触发segue

因此,从interface builder中删除嵌入式控件,只需将其粘贴到视图控制器本身,然后在代码中触发segue

现在,不要再有两段了!没有更多的错误

希望能有所帮助,我花了好几个小时来解决这个问题。

我的解决方案是

[自执行选择器:@selector(moveTo)with object:nil 后延迟:0.5]


遇到了同样的问题。在里面
-(void)textFieldDidBeginEditing:(UITextField *)textField{

        [_textFieldLocation resignFirstResponder]; //adding this line

        FilterLocationViewController *destViewController = (FilterLocationViewController *)[self.storyboard instantiateViewControllerWithIdentifier:@"FilterLocationViewController"];

        [self.navigationController pushViewController:destViewController animated:YES];

}
 [self.navigationController popViewControllerAnimated:YES];
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    UIViewController *vc = [[UIViewController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}