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

iOS14崩溃问题修改建议 #48

Open
jyh1516 opened this issue Dec 1, 2020 · 3 comments
Open

iOS14崩溃问题修改建议 #48

jyh1516 opened this issue Dec 1, 2020 · 3 comments

Comments

@jyh1516
Copy link

jyh1516 commented Dec 1, 2020

if (@available(iOS 13.0, *)) {
    NSEnumerator *frontToBackWindows = [UIApplication.sharedApplication.windows reverseObjectEnumerator];
    for (UIWindow *window in frontToBackWindows) {
        BOOL windowOnMainScreen = window.screen == UIScreen.mainScreen;
        BOOL windowIsVisible = !window.hidden && window.alpha > 0;
        BOOL windowLevelNormal = window.windowLevel == UIWindowLevelNormal;
        if (windowOnMainScreen && windowIsVisible && windowLevelNormal) {
            return [window hitTest:point withEvent:event];
            break;
        }
    }
// return [UIApplication.sharedApplication.keyWindow hitTest:point withEvent:event];
}

这样取最上层window而不是直接拿keyWindow.

DarrenKong pushed a commit to DarrenKong/EBBannerView that referenced this issue Dec 4, 2020
@Best199101
Copy link

swift版本依然会闪退,参考了上面写法

@gorvell
Copy link

gorvell commented Mar 24, 2021

仍然会崩溃

@zzdota
Copy link

zzdota commented Dec 7, 2021

if (@available(iOS 13.0, *)) {
NSEnumerator *frontToBackWindows = [UIApplication.sharedApplication.windows reverseObjectEnumerator];
for (UIWindow *window in frontToBackWindows) {
BOOL windowOnMainScreen = window.screen == UIScreen.mainScreen;
BOOL windowIsVisible = !window.hidden && window.alpha > 0;
BOOL windowLevelNormal = window.windowLevel == UIWindowLevelNormal;
if (windowOnMainScreen && windowIsVisible && windowLevelNormal) {
return [window hitTest:point withEvent:event];
break;
}
}
// return [UIApplication.sharedApplication.keyWindow hitTest:point withEvent:event];
}
这样取最上层window而不是直接拿keyWindow.

貌似只有iOS14会崩溃,iOS15高版本,都是低版本都不会崩溃。。。不过还是建议作者修复一下。

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

No branches or pull requests

4 participants