diff --git a/KVNProgress/Classes/KVNProgress.m b/KVNProgress/Classes/KVNProgress.m index 16cd406..27e1161 100644 --- a/KVNProgress/Classes/KVNProgress.m +++ b/KVNProgress/Classes/KVNProgress.m @@ -501,7 +501,7 @@ + (void)dismissAnimatedWithCompletion:(KVNCompletionBlock)completion // The hud hasn't showed enough time delay = progressView.configuration.minimumDisplayTime - timeIntervalSinceShow; } - + [UIView animateWithDuration:KVNFadeAnimationDuration delay:delay options:(UIViewAnimationOptionCurveEaseIn @@ -534,10 +534,11 @@ + (void)endDismissWithCompletion:(KVNCompletionBlock)completion UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil); if (!progressView.progressWindow.hidden) { - progressView.progressWindow.hidden = YES; - [progressView.keyWindow makeKeyAndVisible]; + [progressView removeProgressWindow]; } + [progressView.keyWindow makeKeyAndVisible]; + [UIApplication sharedApplication].statusBarStyle = [self sharedView].rootControllerStatusBarStyle; } @@ -868,6 +869,8 @@ - (void)setupMotionEffect - (void)addProgressWindow { + [self removeProgressWindow]; + self.keyWindow = [UIApplication sharedApplication].keyWindow; self.progressWindow = [[UIWindow alloc] initWithFrame:self.keyWindow.frame]; @@ -881,6 +884,14 @@ - (void)addProgressWindow [self addToView:self.progressWindow]; } +- (void)removeProgressWindow +{ + if (self.progressWindow) { + self.progressWindow.hidden = YES; + self.progressWindow = nil; + } +} + - (void)addToView:(UIView *)superview { if (self.superview) { @@ -891,25 +902,22 @@ - (void)addToView:(UIView *)superview [superview addSubview:self]; [superview bringSubviewToFront:self]; - if (![superview isKindOfClass:[UITableView class]]) { - // Autolayout messes when superview is a UITableView - NSArray *verticalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[self]|" - options:0 - metrics:nil - views:@{@"self" : self}]; - NSArray *horizontalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|[self]|" - options:0 - metrics:nil - views:@{@"self" : self}]; - - self.constraintsToSuperview = [verticalConstraints arrayByAddingObjectsFromArray:horizontalConstraints]; - - self.translatesAutoresizingMaskIntoConstraints = NO; - [superview addConstraints:verticalConstraints]; - [superview addConstraints:horizontalConstraints]; - - [self layoutIfNeeded]; - } + NSArray *verticalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[self]|" + options:0 + metrics:nil + views:@{@"self" : self}]; + NSArray *horizontalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|[self]|" + options:0 + metrics:nil + views:@{@"self" : self}]; + + self.constraintsToSuperview = [verticalConstraints arrayByAddingObjectsFromArray:horizontalConstraints]; + + self.translatesAutoresizingMaskIntoConstraints = NO; + [superview addConstraints:verticalConstraints]; + [superview addConstraints:horizontalConstraints]; + + [self layoutIfNeeded]; self.alpha = 0.0f;