0

I have uinavigation controller with a view controller named VC1,now i have a button in VC1 that when i click on him i go to view controller VC2,this is how i bring VC2 to screen :

VC2 *tmp = [[VC2 alloc]init];
[[self navigationController] pushViewController:tmp animated:YES];
[tmp release];

now when i click in VC2 on the back button of the navigation to return to VC1 its work but i put in VC2 viewDidDisappear and viewWillDisappear methods,and when i click on the back button this function won't called, any one have any idea?

YosiFZ
  • 7,792
  • 21
  • 114
  • 221

2 Answers2

1

You may call the view[..] methods manually from the UINavigationControllerDelegate callbacks, however the easiest way to ensure that the methods are called by the super implementation of the UINavigationController is just to call them manually once when the UINavigationController is allocated.

See my answer here: iPhone viewWillAppear not firing

So immediately after you have called navController = [[UINavigationController alloc] init.., make sure to call

[navController viewWillAppear:NO];
[navController viewDidAppear:NO];
[navController viewWillDisappear:NO];
[navController viewDidDisappear:NO];

This should ensure events are correctly forwarded to each view controller in the future.

Community
  • 1
  • 1
Sam
  • 3,659
  • 3
  • 36
  • 49
-1

If you want to call the viewWillDisappear/viewDidDisappear methods, your view controller has to do that manually before popping itself off the nav stack. Have a look at this ,you might get an idea how to do it.

Maggie
  • 7,823
  • 7
  • 45
  • 66
  • I think this isn't true. I have a navigationController and a viewController which is popped from the nav stack and viewWillDisappear is called every time. – dasdom Aug 04 '11 at 08:53