【发布时间】:2017-06-17 11:39:53
【问题描述】:
我想得到以前的viewController。
当我从 navigation 菜单中选择任何行时,我有 2 个 UIViewControllers 和 navigationMenu 我想从打开菜单的位置获取 UIViewController 以移动到第二个 UIViewController。
我想知道在这种情况下如何获取以前的UIViewController
我试过了,但数返回 nil:
let n: Int! = self.navigationController?.viewControllers.count
print(n)
let myUIViewController = self.navigationController?.viewControllers[n-2] as! UIViewController
编辑:-
打开菜单代码
let menuButton = UIBarButtonItem.init(title :"open", style: .plain, target: self.revealViewController(), action: #selector(SWRevealViewController.revealToggle(_:)))
navigationItem.leftBarButtonItem = menuButton
【问题讨论】:
-
你用哪个库来做菜单?
-
SWRevealViewController
-
好的,您只想在一个地方知道,或者您想从任何文件中知道?
-
我想知道如何从打开菜单的地方获取 ViewController
标签: ios swift uiviewcontroller