当APP启动时 - 启动SigninView - 它是Okey。接下来如果成功 - 我需要showTripController()。功能工作但没有显示?有什么问题?
/1564677747159774/feed
答案 0 :(得分:0)
首先,您必须在使用窗口之前添加它:
self.window.makeKeyAndVisible()
要记住的另一件事是:
有时候keyWindow可能被nil rootViewController的窗口所取代(在iPhone上显示UIAlertViews,UIActionSheets等),在这种情况下你应该使用UIView的窗口属性。
因此,不要使用rootViewController,而是使用它呈现的顶部:
extension UIApplication {
class func topViewController(base: UIViewController? = UIApplication.sharedApplication().keyWindow?.rootViewController) -> UIViewController? {
if let nav = base as? UINavigationController {
return topViewController(base: nav.visibleViewController)
}
if let tab = base as? UITabBarController {
if let selected = tab.selectedViewController {
return topViewController(base: selected)
}
}
if let presented = base?.presentedViewController {
return topViewController(base: presented)
}
return base
}
}
if let topController = UIApplication.topViewController() {
topController.presentViewController(vc, animated: true, completion: nil)
}
答案 1 :(得分:0)
替换最后3行showTripController,如下所示:
let nc = UINavigationController(rootViewController: cv));
self.window!.rootViewController = nc