Skip to content

Commit ee50263

Browse files
committed
Potential fix for rotation woes seen in #30 #31
1 parent 05cb3f0 commit ee50263

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

Source/MMProgressHUD.m

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
#pragma mark - MMProgressHUD
4242
@interface MMProgressHUD () <MMHudDelegate>
4343

44-
@property (nonatomic, strong) UIView *gradientView;
4544
@property (nonatomic, strong) MMProgressHUDWindow *window;
4645
@property (nonatomic, readwrite, getter = isVisible) BOOL visible;
4746
@property (nonatomic, copy) NSString *title;
@@ -310,6 +309,8 @@ - (MMProgressHUDOverlayView *)overlayView {
310309
if (_overlayView == nil) {
311310
_overlayView = [[MMProgressHUDOverlayView alloc] init];
312311
_overlayView.alpha = 0.f;
312+
_overlayView.autoresizingMask = (UIViewAutoresizingFlexibleHeight |
313+
UIViewAutoresizingFlexibleWidth);
313314
}
314315

315316
return _overlayView;
@@ -419,9 +420,7 @@ - (void)_updateMessageLabelsAnimated:(BOOL)animated {
419420
- (void)_updateHUDAnimated:(BOOL)animated withCompletion:(void(^)(BOOL completed))completionBlock {
420421
MMHudLog(@"Updating %@ with completion...", NSStringFromClass(self.class));
421422

422-
if (self.dismissDelayTimer != nil) {
423-
[self.dismissDelayTimer invalidate], self.dismissDelayTimer = nil;
424-
}
423+
[self killDismissDelayTimer];
425424

426425
if (animated) {
427426
[UIView
@@ -450,6 +449,14 @@ - (void)_updateHUD {
450449
self.hud.center = [self _windowCenterForHUDAnchor:self.hud.layer.anchorPoint];
451450
}
452451

452+
- (void)killDismissDelayTimer {
453+
if ([self.dismissDelayTimer isValid]) {
454+
[self.dismissDelayTimer invalidate];
455+
}
456+
457+
self.dismissDelayTimer = nil;
458+
}
459+
453460
- (CGPoint)_windowCenterForHUDAnchor:(CGPoint)anchor {
454461

455462
CGFloat hudHeight = CGRectGetHeight(self.hud.frame);
@@ -474,9 +481,7 @@ - (CGPoint)_windowCenterForHUDAnchor:(CGPoint)anchor {
474481

475482
#pragma mark - Presentation
476483
- (void)show {
477-
if (self.dismissDelayTimer != nil) {
478-
[self.dismissDelayTimer invalidate], self.dismissDelayTimer = nil;
479-
}
484+
[self killDismissDelayTimer];
480485

481486
NSAssert([NSThread isMainThread], @"Show should be run on main thread!");
482487

@@ -546,7 +551,9 @@ - (void)dismissAfterDelay:(NSTimeInterval)delay {
546551
MMHudLog(@"Preventing delayed dismissal when already dismissed!");
547552
return;
548553
}
549-
[self.dismissDelayTimer invalidate];
554+
555+
[self killDismissDelayTimer];
556+
550557
self.dismissDelayTimer = [NSTimer scheduledTimerWithTimeInterval:delay target:self selector:@selector(dismiss) userInfo:nil repeats:NO];
551558
}
552559

Source/MMProgressHUDWindow.m

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,25 @@ @implementation MMProgressHUDWindow
1313

1414
- (instancetype)init {
1515
if ((self = [super initWithFrame:[[UIScreen mainScreen] bounds]])) {
16-
self.windowLevel = UIWindowLevelStatusBar;
17-
18-
self.backgroundColor = [UIColor clearColor];
16+
[self commonInit];
1917
}
2018
return self;
2119
}
2220

21+
- (instancetype)initWithFrame:(CGRect)frame {
22+
self = [super initWithFrame:frame];
23+
if (self) {
24+
[self commonInit];
25+
}
26+
return self;
27+
}
28+
29+
- (void)commonInit {
30+
self.windowLevel = UIWindowLevelStatusBar;
31+
32+
self.backgroundColor = [UIColor clearColor];
33+
}
34+
2335
- (void)makeKeyAndVisible {
2436
MMHudLog(@"Making key");
2537

0 commit comments

Comments
 (0)