错误:“嵌套的弹出动画可能导致导航栏损坏”

时间:2014-09-08 15:40:54

标签: ios objective-c iphone

我尝试从表(在ViewController B中)获取单元格的文本,并在textView(在ViewController A中)中显示它。一切都很好,第一次,但第二次a在控制台中有错误信息: "嵌套的pop动画可能导致导航栏损坏 在意外状态下完成导航过渡。导航栏子视图树可能已损坏。"

我的代码是: 在ViewController B中

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Retrieve the value of cell selected
self.valeurCell = [NSString stringWithFormat:@"%@", [tableView cellForRowAtIndexPath:indexPath].textLabel.text];

// Send the value of cell in the answer area (class: SendMessagesViewController)
[[NSNotificationCenter defaultCenter] postNotificationName:@"notice" object:self.valeurCell];

}

在ViewController中 (viewDidLoad中)

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dataTransfer:) name:@"notice" object:nil];


-(void) dataTransfer:(NSNotification *) sentObject{

// !!! en test !!!
self.textViewMsg.text = (NSString *) [sentObject object] ;
[self.navigationController popViewControllerAnimated:YES];

}

谢谢

3 个答案:

答案 0 :(得分:6)

viewDidAppear 不安全之前弹出或推送ViewController。执行此代码[self.navigationController popViewControllerAnimated:YES];在调用viewDidAppear()之后。

答案 1 :(得分:1)

我已经定制了我的UITabbarController,我发现在我的 viewDidAppear 函数中,

我没有放[super viewDidAppear:animated];

答案 2 :(得分:0)

不知道是否仍然有用,但我能想到的最简单的答案就是你拿

[self.navigationController popViewControllerAnimated:YES]; 

到你的didSelect方法的末尾,在viewController中。希望它有所帮助!