Skip to content

Commit

Permalink
Merge pull request banchichen#972 from hanl001/master
Browse files Browse the repository at this point in the history
UIApplicationDelegate的window是optional的,因此加了一层判断,防止未实现window时的crash
  • Loading branch information
banchichen authored Sep 8, 2018
2 parents 2df5833 + 90e8766 commit c75f1c7
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,13 @@ - (void)showProgressHUD {
[_progressHUD addSubview:_HUDContainer];
}
[_HUDIndicatorView startAnimating];
[[UIApplication sharedApplication].delegate.window addSubview:_progressHUD];
UIWindow *applicationWindow;
if ([[[UIApplication sharedApplication] delegate] respondsToSelector:@selector(window)]) {
applicationWindow = [[[UIApplication sharedApplication] delegate] window];
} else {
applicationWindow = [[UIApplication sharedApplication] keyWindow];
}
[applicationWindow addSubview:_progressHUD];
[self.view setNeedsLayout];

// if over time, dismiss HUD automatic
Expand Down

0 comments on commit c75f1c7

Please sign in to comment.