How to be alerted when uiviewcontroller is pushed / popped from navigation stack?

You can try UINavigationController delegate methods it calls when object push or pop from navigation controller stack.

Up vote 0 down vote favorite share g+ share fb share tw.

I need to do certain things when my view controller is both pushed or popped from the navigation stack, but don't want to use viewillappear / viewdidappear or viewwilldisappear / viewdiddisappear since those cover cases besides when the view controller is pushed / popped. Is the correct way to go about this to use the navigationcontroller delegate and the navigationController:didShowViewController:animated: and navigationController:willShowViewController:animated:? If not, how is the best way to go about this?

Iphone ios cocoa-touch uiviewcontroller uinavigationcontroller link|improve this question asked Jan 11 at 7:52CoDEFRo414110 85% accept rate.

You can try UINavigationController delegate methods it calls when object push or pop from navigation controller stack. - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated; - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated.

I have not yet used navigatopnCOntrollerDelegate so I am not sure how to use it, but you can also use NSNotification.

To find out when it's pushed, you can use the UINavigationControllerDelegate and implement - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated. This method will fire whenever the viewcontroller is pushed into the navigation stack, and whenever the viewcontroller on top of it is popped off, thus revealing it again. So you have use a flag to figure out if it's been initialized yet, if it hasn't means it just was pushed.

To find out when it's been popped, use this answer: viewWillDisappear: Determine whether view controller is being popped or is showing a sub-view controller.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions