diff --git a/MMProgressHUD.podspec b/MMProgressHUD.podspec index f3044dd..e031d9a 100644 --- a/MMProgressHUD.podspec +++ b/MMProgressHUD.podspec @@ -6,7 +6,7 @@ Pod::Spec.new do |s| s.license = 'MIT' s.author = { "Lars Anderson" => "lars.anderson@mutualmobile.com" } s.source = { - :git => "https://github.com/mutualmobile/MMProgressHUD.git", + :git => "https://github.com/ryanmsmith/MMProgressHUD.git", :tag => s.version.to_s } s.platform = :ios, '5.0' diff --git a/Source/MMProgressHUD+Class.m b/Source/MMProgressHUD+Class.m index 9175cb2..a5a5f41 100755 --- a/Source/MMProgressHUD+Class.m +++ b/Source/MMProgressHUD+Class.m @@ -230,7 +230,82 @@ + (void)showWithTitle:(NSString *)title } } +//hold prior to dismissal + ++ (void)holdWithError:(NSString *)status +{ + [MMProgressHUD holdWithError:status + title:nil]; +} + ++ (void)holdWithError:(NSString *)status + title:(NSString *)title +{ + [MMProgressHUD holdWithError:status + title:title + afterDelay:MMProgressHUDStandardDismissDelay]; +} + ++ (void)holdWithError:(NSString *)status + title:(NSString *)title + afterDelay:(NSTimeInterval)delay +{ + if ([NSThread isMainThread] == NO) + { + dispatch_sync(dispatch_get_main_queue(), ^{ + [[MMProgressHUD sharedHUD] holdWithCompletionState:MMProgressHUDCompletionStateError + title:title + status:status + afterDelay:delay]; + }); + } + else + { + [[MMProgressHUD sharedHUD] holdWithCompletionState:MMProgressHUDCompletionStateError + title:title + status:status + afterDelay:delay]; + } +} + ++ (void)holdWithSuccess:(NSString *)status +{ + [MMProgressHUD holdWithSuccess:status + title:nil]; +} + ++ (void)holdWithSuccess:(NSString *)status + title:(NSString *)title +{ + [MMProgressHUD holdWithSuccess:status + title:title + afterDelay:MMProgressHUDStandardDismissDelay]; +} + ++ (void)holdWithSuccess:(NSString *)status + title:(NSString *)title + afterDelay:(NSTimeInterval)delay +{ + if ([NSThread isMainThread] == NO) + { + dispatch_sync(dispatch_get_main_queue(), ^{ + [[MMProgressHUD sharedHUD] holdWithCompletionState:MMProgressHUDCompletionStateSuccess + title:title + status:status + afterDelay:delay]; + }); + } + else + { + [[MMProgressHUD sharedHUD] holdWithCompletionState:MMProgressHUDCompletionStateSuccess + title:title + status:status + afterDelay:delay]; + } +} + //dismissal + + (void)dismissWithError:(NSString *)status title:(NSString *)title afterDelay:(NSTimeInterval)delay { @@ -269,7 +344,7 @@ + (void)dismissWithError:(NSString *)status afterDelay:delay]; } -+ (void)dismissWithSuccess:(NSString *)status ++ (void)dismissWithSuccess:(NSString *)status title:(NSString *)title afterDelay:(NSTimeInterval)delay { if ([NSThread isMainThread] == NO) { diff --git a/Source/MMProgressHUD.h b/Source/MMProgressHUD.h index 38c2158..78931af 100755 --- a/Source/MMProgressHUD.h +++ b/Source/MMProgressHUD.h @@ -138,6 +138,12 @@ This message will be presented to the user when a cancelBlock is present after t @property (nonatomic, assign) Class progressViewClass; #pragma mark - Instance Methods + +- (void)holdWithCompletionState:(MMProgressHUDCompletionState)completionState + title:(NSString *)title + status:(NSString *)status + afterDelay:(NSTimeInterval)delay; + - (void)showWithTitle:(NSString *)title status:(NSString *)status confirmationMessage:(NSString *)confirmationMessage @@ -334,6 +340,39 @@ This message will be presented to the user when a cancelBlock is present after t status:(NSString *)status images:(NSArray *)images; + +//----------------------------------------------- +/** @name Hold prior to dismissal */ +//----------------------------------------------- + +/** Holds the shared HUD with the current presentationStyle in an error-state. Dismiss with tap. + + @param message Error message to display to the user. + */ ++ (void)holdWithError:(NSString *)message; + +/** Holds the shared HUD with the current presentationStyle in an error-state. Dismiss with tap. + + @param message Error message to display to the user. + @param title Error title to display to the user. + */ ++ (void)holdWithError:(NSString *)message + title:(NSString *)title; + +/** Holds the shared HUD with the current presentationStyle in an error-state. Dismiss with tap. + + @param message Success message to display to the user. + */ ++ (void)holdWithSuccess:(NSString *)message; + +/** Holds the shared HUD with the current presentationStyle in an error-state. Dismiss with tap. + + @param message Success message to display to the user. + @param title Success title to display to the user. + */ ++ (void)holdWithSuccess:(NSString *)message + title:(NSString *)title; + //----------------------------------------------- /** @name Dismissal */ //----------------------------------------------- @@ -347,6 +386,9 @@ This message will be presented to the user when a cancelBlock is present after t */ + (void)dismissAfterDelay:(NSTimeInterval)delay; + + + #pragma mark - Dismiss with Error /** Dismisses the shared HUD with the current presentationStyle in an error-state after a user-specified delay. diff --git a/Source/MMProgressHUD.m b/Source/MMProgressHUD.m index 77828d7..0545dc5 100755 --- a/Source/MMProgressHUD.m +++ b/Source/MMProgressHUD.m @@ -147,6 +147,31 @@ - (void)dismissWithCompletionState:(MMProgressHUDCompletionState)completionState } } +- (void)holdWithCompletionState:(MMProgressHUDCompletionState)completionState + title:(NSString *)title + status:(NSString *)status + afterDelay:(NSTimeInterval)delay +{ + if (title) + { + self.title = title; + } + + if (status) + { + self.status = status; + } + + self.hud.completionState = completionState; + + if (self.isVisible) + { + [self _updateHUDAnimated:YES withCompletion:^(BOOL completed) { + self.confirmed = YES; + }]; + } +} + - (void)updateProgress:(CGFloat)progress withStatus:(NSString *)status title:(NSString *)title{ [self setProgress:progress]; @@ -455,14 +480,15 @@ - (CGPoint)_windowCenterForHUDAnchor:(CGPoint)anchor { CGFloat hudHeight = CGRectGetHeight(self.hud.frame); CGPoint position; - if (UIInterfaceOrientationIsPortrait([[self.window rootViewController] interfaceOrientation])) { + CGFloat systemVersion = [[[UIDevice currentDevice] systemVersion] floatValue]; + if (UIInterfaceOrientationIsPortrait([[self.window rootViewController] interfaceOrientation]) || systemVersion>=8) { CGFloat y = roundf(self.window.center.y + (anchor.y - 0.5f) * hudHeight); CGFloat x = roundf(self.window.center.x); position = CGPointMake(x, y); } - else { + else if (UIInterfaceOrientationIsLandscape([[self.window rootViewController] interfaceOrientation])) { CGFloat x = roundf(self.window.center.y); CGFloat y = roundf(self.window.center.x + (anchor.y - 0.5f) * hudHeight); @@ -709,7 +735,7 @@ - (void)_handleTap:(UITapGestureRecognizer *)recognizer { self.cancelBlock(); } - self.hud.completionState = MMProgressHUDCompletionStateError; +// self.hud.completionState = MMProgressHUDCompletionStateNone; [self.hud setNeedsUpdate:YES]; [self.hud updateAnimated:YES withCompletion:^(__unused BOOL completed) { diff --git a/Source/MMProgressHUDWindow.m b/Source/MMProgressHUDWindow.m index e3ece3d..7aaf564 100755 --- a/Source/MMProgressHUDWindow.m +++ b/Source/MMProgressHUDWindow.m @@ -52,25 +52,25 @@ - (void)setRootViewController:(UIViewController *)rootViewController { } - (void)orientRootViewControllerForOrientation:(UIInterfaceOrientation)interfaceOrientation { - CGAffineTransform transform; - - switch (interfaceOrientation) { - case UIInterfaceOrientationLandscapeRight: - transform = CGAffineTransformMakeRotation(M_PI_2); - break; - case UIInterfaceOrientationLandscapeLeft: - transform = CGAffineTransformMakeRotation(-M_PI_2); - break; - case UIInterfaceOrientationPortraitUpsideDown: - transform = CGAffineTransformMakeRotation(M_PI); - break; - default: - case UIInterfaceOrientationPortrait: - transform = CGAffineTransformIdentity; - break; - } - - self.rootViewController.view.transform = transform; +// CGAffineTransform transform; +// +// switch (interfaceOrientation) { +// case UIInterfaceOrientationLandscapeRight: +// transform = CGAffineTransformMakeRotation(M_PI_2); +// break; +// case UIInterfaceOrientationLandscapeLeft: +// transform = CGAffineTransformMakeRotation(-M_PI_2); +// break; +// case UIInterfaceOrientationPortraitUpsideDown: +// transform = CGAffineTransformMakeRotation(M_PI); +// break; +// default: +// case UIInterfaceOrientationPortrait: +// transform = CGAffineTransformIdentity; +// break; +// } +// +// self.rootViewController.view.transform = transform; } - (void)dealloc {