【发布时间】:2016-09-08 05:23:38
【问题描述】:
在我的一个视图中,我正在创建一个 rootViewController:
dispatch_async(dispatch_get_main_queue()) {
let pageController = UIPageViewController(transitionStyle: .Scroll, navigationOrientation: .Horizontal, options: nil)
let nav = RootDJasUserVC(rootViewController: pageController)
appDelegate.window = UIWindow(frame: UIScreen.mainScreen().bounds)
appDelegate.window?.rootViewController = nav
appDelegate.window?.makeKeyAndVisible()
}
使用 RootDJasUserVC 的视图我正在调用另一个函数来访问另一个 rootViewController:
dispatch_async(dispatch_get_main_queue()) {
let pageController = UIPageViewController(transitionStyle: .Scroll, navigationOrientation: .Horizontal, options: nil)
let nav = RootVC(rootViewController: pageController)
appDelegate.window = UIWindow(frame: UIScreen.mainScreen().bounds)
appDelegate.window?.rootViewController = nav
appDelegate.window?.makeKeyAndVisible()
}
我不想回到RootDJasUserVC,但我希望RootDJasUserVC 是全新加载的。目前,当我返回RootDJasUserVC(与第一个代码块中的功能相同)时,viewDidLoad 将不会被执行,因为视图显然仍在某个地方加载。
如何正确地“关闭”这样的 rootViewController 以使其“重新加载”?非常感谢您的帮助。
PS。我想做的是在RootDJasUserVC:
dismissViewControllerAnimated(true, completion: nil)
但是当我执行它时什么都没有发生。
PPS。这些 rootViewController 是 UINavigationController 的子类
【问题讨论】:
-
您的链接上的解决方案对我不起作用,即使它是相似的。我想解雇一个“rootViewController”,只是一个viewController。如果我点击了一个声明为该方法的按钮,它就不起作用。 ->什么都没发生
-
@DavidSeek 查看编辑后的代码
-
@DavidSeek 检查答案的编辑 3
-
@DavidSeek 查看我的答案的最后编辑,希望对您有所帮助
标签: ios swift uiviewcontroller