iOS - 确定以前在UINavigationController中显示的UIViewController

Pet*_*rbo 5 cocoa-touch objective-c uinavigationcontroller ios

我需要确定UIViewController以前在a中显示的内容UINavigationController.我的导航深度为3级,在第2级我需要确定我是否从第1级推进到此处,或者是否从第3级弹出这里.我怎么能这么容易地做到这一点?

Ray*_*eck 4

实现 UINavigationControllerDelegate 方法:

 - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
Run Code Online (Sandbox Code Playgroud)

并查询它以找出当前显示的视图控制器:

 navigationController.topViewController
Run Code Online (Sandbox Code Playgroud)

这就是你来自的地方。