Xcode 版本更新新增了SceneDelegate,SVProgressHUD的作者在设置HUDView的中心位置时使用的是UIApplication.sharedApplication.delegate.window.bounds 获取的,而版本更新之后获取不到正确的rect,因此把这部分代码进行调整。(鄙人测试没问题)
代码调整:
SVProgressHUD.m中引入#import "SceneDelegate.h" ,
修改 -(void)positionHUD:(NSNotification*)notification 方法开头位置
#if !defined(SV_APP_EXTENSIONS) && TARGET_OS_IOS
if (@available(ios 13.0, *)) {
UIWindowScene *windowScene = (UIWindowScene *)[[[UIApplication sharedApplication] connectedScenes] allObjects].firstObject;
SceneDelegate *delegate =(SceneDelegate *)windowScene.delegate;
self.frame = delegate.window.bounds;
}else {
self.frame = [[[UIApplication sharedApplication] delegate] window].bounds;
}
UIInterfaceOrientation orientation = UIApplication.sharedApplication.statusBarOrientation;
#elif !defined(SV_APP_EXTENSIONS) && !TARGET_OS_IOS
if (@available(ios 13.0, *)) {
UIWindowScene *windowScene = (UIWindowScene *)[[[UIApplication sharedApplication] connectedScenes] allObjects].firstObject;
SceneDelegate *delegate =(SceneDelegate *)windowScene.delegate;
self.frame = delegate.window.bounds;
}else {
self.frame = [[[UIApplication sharedApplication] delegate] window].bounds;
}
#else
或者更简单的调整(可能会出现其他问题,不建议使用):
修改 -(void)positionHUD:(NSNotification*)notification 方法开头位置
#if !defined(SV_APP_EXTENSIONS) && TARGET_OS_IOS
self.frame = UIScreen.mainScreen.bounds;
UIInterfaceOrientation orientation = UIApplication.sharedApplication.statusBarOrientation;
#elif !defined(SV_APP_EXTENSIONS) && !TARGET_OS_IOS
self.frame = UIScreen.mainScreen.bounds;
#else