From 604e2ad8fb7e5646d2ecbce36c5114373a48932b Mon Sep 17 00:00:00 2001 From: Cocody <50937036@qq.com> Date: Sun, 24 Jul 2016 23:13:21 +0800 Subject: [PATCH] =?UTF-8?q?FIX:=20executing=20[KVNProgress=20showProgress:?= =?UTF-8?q?=200=20status:=20@=20"Uploading=20..."]=20=EF=BC=8Cafter=20a=20?= =?UTF-8?q?very=20short=20time=20to=20perform=20[KVNProgress=20showSuccess?= =?UTF-8?q?],=20will=20lead=20progressWindow=20not=20be=20properly=20remov?= =?UTF-8?q?ed.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- KVNProgress/Classes/KVNProgress.m | 52 ++++++++++++++++++------------- 1 file changed, 30 insertions(+), 22 deletions(-) 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;