Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

获取rootViewController发生错误的问题 #143

Open
FunnyerFeng opened this issue May 27, 2020 · 1 comment
Open

获取rootViewController发生错误的问题 #143

FunnyerFeng opened this issue May 27, 2020 · 1 comment

Comments

@FunnyerFeng
Copy link

FunnyerFeng commented May 27, 2020

我在使用CocoaDebug和URLNavigator 开发程序时,H5 全屏播放视频,返回
if let windowRootViewController = window.rootViewController, window.isKeyWindow {
rootViewController = windowRootViewController
break
}
这个地方获取的rootViewController 就不是项目内的控制器了,isKeyWindow可能是alert 级别的window,所以个人感觉这样获取的keyWindow比较合适:
var keyWindow: UIWindow? = nil
let windows = UIApplication.shared.windows
for tmp in windows{
if tmp.windowLevel == UIWindow.Level.normal{
keyWindow = tmp
break
}
}
var rootVC = keyWindow?.rootViewController

@CodeForFunFun
Copy link

Same issue...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants