Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I know when a `UIViewController` has been just pushed from a `UINavigationViewController`?

How can I know when a UIViewController has been just pushed from a UINavigationViewController ?

I obviously don't want to use viewDidAppear because that's method is called everytime that view appears, not just when it's pushed.

viewDidLoad is called before the view controller is pushed and I don't have the reference to the navigationController available

like image 685
aneuryzm Avatar asked Dec 20 '25 23:12

aneuryzm


1 Answers

You can check this from of navigation viewcontrollers array

//Eg:
//Maintain your navigation object:
@property (strong, nonatomic) UINavigationController *navController;

//use:
   if([[self.navController.viewControllers lastObject] class] == [your view controoler class]) {
  // your view controller is present in navigation stack
}
like image 194
Suhas Arvind Patil Avatar answered Dec 23 '25 14:12

Suhas Arvind Patil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!