IPhone - Get the controller that pushed me

When I clicked on the controller, is there any way to get the controller that pressed it (without sending)? Or the first one?

thank

+3
source share
2 answers

You can get all view controllers from a property navigationController.viewControllers. And a controller which pushed the current visible controller [navigationController.viewControllers objectAtIndex:[navigationController.viewControllers count] - 2].

+4
source

Swift version :

let numberOfElements: Int? = self.navigationController?.viewControllers.count
let vc: ViewController = self.navigationController?.viewControllers[numberOfElements! - 2] as ViewController
0
source

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


All Articles