문제

When I pushed a controller, is there a way to get the controller which pushed it (without sending it)? Or the first one?

Thanks

도움이 되었습니까?

해결책

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].

다른 팁

Swift version:

let numberOfElements: Int? = self.navigationController?.viewControllers.count
let vc: ViewController = self.navigationController?.viewControllers[numberOfElements! - 2] as ViewController
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top