You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
guard let currentWindows = self.sharedApplication?.windows else { return nil }
var rootViewController: UIViewController?
for window in currentWindows {
if let windowRootViewController = window.rootViewController {
rootViewController = windowRootViewController
break
}
}
Activity
nameIsYong commentedon Nov 7, 2018
let navigator:Navigator = AppDelegate.appNavigator() navigator.push(url)这里push有时候返回 nil
public func push(_ url: URLConvertible, context: Any? = nil, from: UINavigationControllerType? = nil, animated: Bool = true) -> UIViewController? { return self.pushURL(url, context: context, from: from, animated: animated) }cdoky commentedon Nov 7, 2018
你这个问题我就没遇到过
你检查一下URL是否匹配到了,或者是提供一个demo
nameIsYong commentedon Nov 7, 2018
好的,谢谢,我再琢磨一下。
kivenZheng commentedon Nov 27, 2018
请问可以在TabBarController里使用吗?
nameIsYong commentedon Nov 27, 2018
可以的。
fooval-shen commentedon Dec 11, 2018
我也遇到这个问题, 后面发现了 bug在这个代码里面
guard let currentWindows = self.sharedApplication?.windows else { return nil }
var rootViewController: UIViewController?
for window in currentWindows {
if let windowRootViewController = window.rootViewController {
rootViewController = windowRootViewController
break
}
}
比如在其他window 也有rootViewController的时候, 并且这个时候这个windows 不是key window, 这个时候获取到rootViewControoler 就不是当前 可见的 rootviewController