2

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

dev99
  • 51
  • 1
  • 6

3 Answers3

6

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

Kateryna Gridina
  • 834
  • 9
  • 13
  • i tryed to put the code [self.navigationController popViewControllerAnimated:YES]; in "viewDidAppear" but doesn't work – dev99 Sep 08 '14 at 16:33
  • Maybe you try to pop view controller before previously created controller still animated, take a look at this answer http://stackoverflow.com/questions/5301014/ios-popviewcontroller-unexpected-behavior – Kateryna Gridina Sep 08 '14 at 21:17
1

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

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

felixwcf
  • 2,078
  • 1
  • 28
  • 45
0

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!

Iree
  • 358
  • 3
  • 13