Skip to content

Commit ec7d1e4

Browse files
committed
Fix show multiple Hud’s and them to hide them
1 parent aec802b commit ec7d1e4

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

MBProgressHUD.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ NS_ASSUME_NONNULL_BEGIN
105105
/// @name Showing and hiding
106106

107107
/**
108-
* Finds the top-most HUD subview and hides it. The counterpart to this method is showHUDAddedTo:animated:.
108+
* Finds the top-most HUD subview that hasn't finished and hides it. The counterpart to this method is showHUDAddedTo:animated:.
109109
*
110110
* @note This method sets removeFromSuperViewOnHide. The HUD will automatically be removed from the view hierarchy when hidden.
111111
*
@@ -120,7 +120,7 @@ NS_ASSUME_NONNULL_BEGIN
120120
+ (BOOL)hideHUDForView:(UIView *)view animated:(BOOL)animated;
121121

122122
/**
123-
* Finds the top-most HUD subview and returns it.
123+
* Finds the top-most HUD subview that hasn't finished and returns it.
124124
*
125125
* @param view The view that is going to be searched.
126126
* @return A reference to the last HUD subview discovered.

MBProgressHUD.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ + (MBProgressHUD *)HUDForView:(UIView *)view {
8080
NSEnumerator *subviewsEnum = [view.subviews reverseObjectEnumerator];
8181
for (UIView *subview in subviewsEnum) {
8282
if ([subview isKindOfClass:self]) {
83-
return (MBProgressHUD *)subview;
83+
MBProgressHUD *hud = (MBProgressHUD *)subview;
84+
if (hud.hasFinished == NO) {
85+
return hud;
86+
}
8487
}
8588
}
8689
return nil;

0 commit comments

Comments
 (0)