2
votes

i try to get the text of a cell from a table (in ViewController B) and to display it in a textView (in ViewController A). Everything is fine the first time but when second time a have an error message in the console: "nested pop animation can result in corrupted navigation bar Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted."

My code is : In 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];

}

In ViewController A (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];

}

Thank you

3

3 Answers

6
votes

To make pop or push of ViewController before viewDidAppear is not safe. Perform this code [self.navigationController popViewControllerAnimated:YES]; after viewDidAppear() was called.

1
votes

I have customized my UITabbarController, and I found out that in my viewDidAppear function,

I didn't put [super viewDidAppear:animated];.

0
votes

Don't know if still usefull, but the easiest answer I can think of is that you take the

[self.navigationController popViewControllerAnimated:YES]; 

to the end of your didSelect method, in viewControllerB.

Hope it helps!