From 31f86c3a8e631a5b1a5d23d72240a61d16b7d133 Mon Sep 17 00:00:00 2001 From: NikoTung Date: Wed, 13 Nov 2013 09:21:28 +0800 Subject: [PATCH 1/3] fix when orientation change and keyboard showed which make the view on the wrong position --- URBAlertView.m | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/URBAlertView.m b/URBAlertView.m index c8b1fcd..46d0106 100644 --- a/URBAlertView.m +++ b/URBAlertView.m @@ -1150,7 +1150,7 @@ - (void)showOverlay:(BOOL)show { self.overlay = [URBAlertWindowOverlay new]; URBAlertWindowOverlay *overlay = self.overlay; overlay.opaque = NO; - overlay.alertView = self; +// overlay.alertView = self; overlay.frame = self.window.bounds; overlay.alpha = 0.0; } @@ -1284,15 +1284,30 @@ - (void)keyboardWillHide:(NSNotification *)note { } - (void)adjustToKeyboardBounds:(CGRect)bounds { - CGRect screenBounds = [[UIScreen mainScreen] bounds]; - CGFloat height = CGRectGetHeight(screenBounds) - CGRectGetHeight(bounds); + CGRect screenBounds = [[UIScreen mainScreen] bounds]; CGRect frame = self.frame; - frame.origin.y = (height - CGRectGetHeight(self.bounds)) / 2.0; + CGFloat height = CGRectGetHeight(screenBounds) - CGRectGetHeight(bounds); + UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; + if (UIDeviceOrientationIsLandscape(orientation)) { + height = CGRectGetWidth(screenBounds)-CGRectGetWidth(bounds); + frame.origin.x = (height - CGRectGetWidth(self.bounds)) /2.0 ; + if (bounds.origin.x == 0) { + frame.origin.x = frame.origin.x +CGRectGetWidth(bounds); + } + } + else + { + frame.origin.y = (height - CGRectGetHeight(self.bounds)) / 2.0; + if (bounds.origin.y == 0) { + frame.origin.y += CGRectGetHeight(bounds); + } + } if (CGRectGetMinY(frame) < 0) { NSLog(@"warning: dialog is clipped, origin negative (%f)", CGRectGetMinY(frame)); } - + + [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{ self.frame = frame; } completion:nil]; From 0139c5f8fc75945292d09787bec51686c12c0867 Mon Sep 17 00:00:00 2001 From: NikoTung Date: Wed, 13 Nov 2013 09:27:40 +0800 Subject: [PATCH 2/3] fix comment --- URBAlertView.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/URBAlertView.m b/URBAlertView.m index 46d0106..d426ca6 100644 --- a/URBAlertView.m +++ b/URBAlertView.m @@ -201,6 +201,11 @@ - (void)initialize { [self build]; } +- (void)dealloc +{ + NSLog(@"dealloc ----- %s",__FUNCTION__); +} + - (void)setHandlerBlock:(URBAlertViewBlock)block { self.block = block; } From df2629a25c8fd8708801450c7806b50df50315ea Mon Sep 17 00:00:00 2001 From: NikoTung Date: Wed, 13 Nov 2013 09:28:44 +0800 Subject: [PATCH 3/3] fix dealloc never be called retain cycle --- URBAlertView.m | 1 - 1 file changed, 1 deletion(-) diff --git a/URBAlertView.m b/URBAlertView.m index d426ca6..80f8835 100644 --- a/URBAlertView.m +++ b/URBAlertView.m @@ -203,7 +203,6 @@ - (void)initialize { - (void)dealloc { - NSLog(@"dealloc ----- %s",__FUNCTION__); } - (void)setHandlerBlock:(URBAlertViewBlock)block {