Before resorting to custom flags I wanted to check this with you people.
Is there a built-in way to determine in viewWillAppear:
or viewWillDisappear:
whether the UIViewController is 'newly pushed' onto a UINavigationController's stack, or whether the navigation controller has popped another view off, revealing this one? I want to execute some one-off code the first time the view appears. Because the self.bounds
property needs to be set, the viewDidLoad:
method is not the right place.
I was hoping to get some results with what I'm using to determine something similar on viewWillDisappear:
, but on the first viewWillAppear:
the index is already set to 1:
[self.navigationController.viewControllers indexOfObject:self]
So this is a useless snippet. Any ideas?
The way I handle this is as follows... Have a flag which is initially set to false, when you push a child view controller onto your navigation controller set this flag to true, no on the viewDidAppear if the flag is false then it is the initial load if true then it is being returned to from a child controller popping off the navigation stack.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With