Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What method is called after tap back button in ios

I have 2 View Controllers with Navigation Controller. When I Use [self.navigationController popViewControllerAnimated:YES]; in the second one - the first one opens but the methods in viewDidLoad don't called. What are the methods called in the first one controller in this situation?

like image 317
ShurupuS Avatar asked Apr 05 '13 07:04

ShurupuS


People also ask

What is a navigation controller?

NavController manages app navigation within a NavHost . Apps will generally obtain a controller directly from a host, or by using one of the utility methods on the Navigation class rather than create a controller directly. Navigation flows and destinations are determined by the navigation graph owned by the controller.

How can remove back button in iOS?

Please navigate to Advanced Website Kiosk Settings–>Navigation–>Disable back button. Kindly enable this restriction to disallow the usage of the back button on the iOS device.


2 Answers

The navigation controller sends viewWillAppear: to a view controller before putting its view on the screen, and viewDidAppear: after.

Inside viewWillAppear: and viewDidAppear:, the view controller can check self.isMovingToParentViewController. If isMovingToParentViewController is YES, the view controller is being added to the navigation controller in the first place (presumably because it's the navigation controller's root view controller, or because it is being pushed). If isMovingToParentViewController is NO, the view controller is already in the navigation controller's stack, and another view controller is being popped to reveal it.

Read “Handling View-Related Notifications” in the UIViewController class reference.

like image 64
rob mayoff Avatar answered Sep 26 '22 04:09

rob mayoff


In that case viewWillAppear method will be called.

-(void)viewWillAppear:(BOOL)animated
{

}
like image 33
Dilip Avatar answered Sep 22 '22 04:09

Dilip