@@ -1641,8 +1641,7 @@ - (void)presentPopoverFromRect:(CGRect)aRect
16411641
16421642 if ((options & WYPopoverAnimationOptionScale) == WYPopoverAnimationOptionScale)
16431643 {
1644- CGAffineTransform startTransform = [self transformTranslateForArrowDirection: containerView.arrowDirection];
1645- startTransform = CGAffineTransformScale (startTransform, 0.1 , 0.1 );
1644+ CGAffineTransform startTransform = [self transformForArrowDirection: containerView.arrowDirection];
16461645 containerView.transform = startTransform;
16471646 }
16481647
@@ -1777,13 +1776,24 @@ - (void)presentPopoverAsDialogAnimated:(BOOL)aAnimated
17771776 completion: completion];
17781777}
17791778
1780- - (CGAffineTransform)transformTranslateForArrowDirection : (WYPopoverArrowDirection)arrowDirection
1779+ - (CGAffineTransform)transformForArrowDirection : (WYPopoverArrowDirection)arrowDirection
17811780{
17821781 CGAffineTransform transform = containerView.transform ;
17831782
1783+ UIInterfaceOrientation orientation = [[UIApplication sharedApplication ] statusBarOrientation ];
1784+
1785+ CGSize containerViewSize = containerView.frame .size ;
1786+
17841787 if (containerView.arrowHeight > 0 )
17851788 {
1786- CGSize containerViewSize = containerView.frame .size ;
1789+ if (UIDeviceOrientationIsLandscape (orientation)) {
1790+ containerViewSize.width = containerView.frame .size .height ;
1791+ containerViewSize.height = containerView.frame .size .width ;
1792+ }
1793+
1794+ // WY_LOG(@"containerView.arrowOffset = %f", containerView.arrowOffset);
1795+ // WY_LOG(@"containerViewSize = %@", NSStringFromCGSize(containerViewSize));
1796+ // WY_LOG(@"orientation = %@", WYStringFromOrientation(orientation));
17871797
17881798 if (arrowDirection == WYPopoverArrowDirectionDown)
17891799 {
@@ -1797,15 +1807,17 @@ - (CGAffineTransform)transformTranslateForArrowDirection:(WYPopoverArrowDirectio
17971807
17981808 if (arrowDirection == WYPopoverArrowDirectionRight)
17991809 {
1800- transform = CGAffineTransformTranslate (transform, containerView. frame . size .width / 2 , containerView.arrowOffset );
1810+ transform = CGAffineTransformTranslate (transform, containerViewSize .width / 2 , containerView.arrowOffset );
18011811 }
18021812
18031813 if (arrowDirection == WYPopoverArrowDirectionLeft)
18041814 {
1805- transform = CGAffineTransformTranslate (transform, -containerView. frame . size .width / 2 , containerView.arrowOffset );
1815+ transform = CGAffineTransformTranslate (transform, -containerViewSize .width / 2 , containerView.arrowOffset );
18061816 }
18071817 }
18081818
1819+ transform = CGAffineTransformScale (transform, 0.01 , 0.01 );
1820+
18091821 return transform;
18101822}
18111823
@@ -2117,8 +2129,6 @@ - (void)positionPopover
21172129 containerFrame.origin = WYPointRelativeToOrientation (containerOrigin, containerFrame.size , orientation);
21182130
21192131 containerView.frame = containerFrame;
2120-
2121- WY_LOG (@" orientation = %@ " , WYStringFromOrientation (orientation));
21222132}
21232133
21242134- (void )dismissPopoverAnimated : (BOOL )aAnimated
@@ -2159,27 +2169,27 @@ - (void)dismissPopoverAnimated:(BOOL)aAnimated
21592169 completion : (void (^)(void ))completion
21602170 callDelegate : (BOOL )callDelegate
21612171{
2162- #ifdef WY_BASE_SDK_7_ENABLED
2163- if ([inView.window respondsToSelector: @selector (setTintAdjustmentMode: )]) {
2164- for (UIView *subview in inView.window .subviews ) {
2165- if (subview != containerView) {
2166- [subview setTintAdjustmentMode: UIViewTintAdjustmentModeAutomatic];
2167- }
2168- }
2169- }
2170- #endif
2171-
21722172 CGFloat duration = self.animationDuration ;
21732173 WYPopoverAnimationOptions style = aOptions;
21742174
21752175 __weak __typeof__ (self) weakSelf = self;
21762176
21772177 void (^afterCompletionBlock)() = ^() {
2178+
2179+ #ifdef WY_BASE_SDK_7_ENABLED
2180+ if ([inView.window respondsToSelector: @selector (setTintAdjustmentMode: )]) {
2181+ for (UIView *subview in inView.window .subviews ) {
2182+ if (subview != containerView) {
2183+ [subview setTintAdjustmentMode: UIViewTintAdjustmentModeAutomatic];
2184+ }
2185+ }
2186+ }
2187+ #endif
2188+
21782189 __typeof__ (self) strongSelf = weakSelf;
21792190
21802191 if (strongSelf)
21812192 {
2182- [strongSelf->containerView removeFromSuperview ];
21832193 strongSelf->containerView = nil ;
21842194
21852195 [strongSelf->overlayView removeFromSuperview ];
@@ -2205,6 +2215,10 @@ - (void)dismissPopoverAnimated:(BOOL)aAnimated
22052215 };
22062216
22072217 void (^completionBlock)() = ^() {
2218+
2219+ __typeof__ (self) strongSelf = weakSelf;
2220+ [strongSelf->containerView removeFromSuperview ];
2221+
22082222 if (aAnimated)
22092223 {
22102224 [UIView animateWithDuration: duration animations: ^{
@@ -2265,8 +2279,7 @@ - (void)dismissPopoverAnimated:(BOOL)aAnimated
22652279
22662280 if ((style & WYPopoverAnimationOptionScale) == WYPopoverAnimationOptionScale)
22672281 {
2268- CGAffineTransform endTransform = [self transformTranslateForArrowDirection: strongSelf->containerView.arrowDirection];
2269- endTransform = CGAffineTransformScale (endTransform, 0.1 , 0.1 );
2282+ CGAffineTransform endTransform = [self transformForArrowDirection: strongSelf->containerView.arrowDirection];
22702283 strongSelf->containerView .transform = endTransform;
22712284 }
22722285 }
0 commit comments