Navigation Bar Reverse Button Method

I want to go to a specific page in my application, and I also do not want to create any custom back button for this. If I can override the navigation bar button method so that I can call poptorootviewcontroller.so, I can go to a specific page. Does anyone know what a method is that is called by the button of the navigation bar, and if we can use it?

+4
source share
3 answers

You can try this. Write your logic in this native method.

-(void) viewWillDisappear:(BOOL)animated { [super viewWillDisappear:YES]; // Your Code } 
+6
source

You will need to specify a name and implementation for the button method. Since there is no standard method.

 self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(backButtonPressed)] autorelease]; 

implementation.

 -(void) backButtonPressed { NSLog(@"Back button presses"); } 
+1
source

Try using the code below:

 NSArray * viewController = self.navigationController.viewControllers; if([viewController count] > 3) { UIViewController * vc = [viewController objectAtIndex:0]; [self.navigationController popToViewController:vc animated:YES]; } 
+1
source

Source: https://habr.com/ru/post/1402637/


All Articles