如果我在 UINavigationController
上推送 View Controller 和/或呈现模态视图 Controller ,我如何找出最顶部的 UIViewController
是什么?或者就我而言,我想知道某个 UITableViewController
是否是最顶层的。
我尝试使用:
self.navigationController.topViewController == self
...但这不起作用。我猜它失败了,因为我在它上面展示了模态视图 Controller ,并且 topViewController
只跟踪在 UINavigationController
上推送了哪些 View (如反对那些以模态形式呈现的)。
最佳答案
你想要visibleViewController
:
The currently visible view can belong either to the view controller at the top of the navigation stack or to a view controller that was presented modally.
关于objective-c - 获取最顶层的 UIViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4067692/