From f4c8dec6077f2caa9b8bd364e1cf07a5746d811f Mon Sep 17 00:00:00 2001 From: shSuperLee Date: Fri, 25 Mar 2022 11:51:50 +0800 Subject: [PATCH] Update YBIBUtilities.m fix: ApplicationDelegate get window crash --- YBImageBrowser/Helper/YBIBUtilities.m | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/YBImageBrowser/Helper/YBIBUtilities.m b/YBImageBrowser/Helper/YBIBUtilities.m index ba074f8..6da35b0 100644 --- a/YBImageBrowser/Helper/YBIBUtilities.m +++ b/YBImageBrowser/Helper/YBIBUtilities.m @@ -71,7 +71,8 @@ BOOL YBIBIsIphoneXSeries(void) { CGFloat YBIBStatusbarHeight(void) { CGFloat height = 0; if (@available(iOS 11.0, *)) { - height = UIApplication.sharedApplication.delegate.window.safeAreaInsets.top; +// height = UIApplication.sharedApplication.delegate.window.safeAreaInsets.top; + height = UIApplication.sharedApplication.keyWindow.safeAreaInsets.top; } if (height <= 0) { height = UIApplication.sharedApplication.statusBarFrame.size.height; @@ -85,7 +86,8 @@ CGFloat YBIBStatusbarHeight(void) { CGFloat YBIBSafeAreaBottomHeight(void) { CGFloat bottom = 0; if (@available(iOS 11.0, *)) { - bottom = UIApplication.sharedApplication.delegate.window.safeAreaInsets.bottom; +// bottom = UIApplication.sharedApplication.delegate.window.safeAreaInsets.bottom; + bottom = UIApplication.sharedApplication.keyWindow.safeAreaInsets.bottom; } return bottom; }