iPhone - Get controller which pushed me
-
01-10-2019 - |
Question
When I pushed a controller, is there a way to get the controller which pushed it (without sending it)? Or the first one?
Thanks
Solution
You can get all view controllers from navigationController.viewControllers
property.
And the controller which pushed the currently visible controller is [navigationController.viewControllers objectAtIndex:[navigationController.viewControllers count] - 2]
.
OTHER TIPS
Swift version:
let numberOfElements: Int? = self.navigationController?.viewControllers.count
let vc: ViewController = self.navigationController?.viewControllers[numberOfElements! - 2] as ViewController
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow