@@ -1619,15 +1619,21 @@ - (void)presentPopoverFromRect:(CGRect)aRect
16191619
16201620 [UIView animateWithDuration: animationDuration animations: ^{
16211621 __typeof__ (self) strongSelf = weakSelf;
1622- strongSelf->overlayView .alpha = 1 ;
1623- strongSelf->containerView .alpha = 1 ;
1624- strongSelf->containerView .transform = endTransform;
1622+ if (strongSelf)
1623+ {
1624+ strongSelf->overlayView .alpha = 1 ;
1625+ strongSelf->containerView .alpha = 1 ;
1626+ strongSelf->containerView .transform = endTransform;
1627+ }
16251628 } completion: ^(BOOL finished) {
16261629 __typeof__ (self) strongSelf = weakSelf;
16271630
1628- if ([ strongSelf->viewController isKindOfClass: [UINavigationController class ]] == NO )
1631+ if (strongSelf)
16291632 {
1630- [strongSelf->viewController viewDidAppear: YES ];
1633+ if ([strongSelf->viewController isKindOfClass: [UINavigationController class ]] == NO )
1634+ {
1635+ [strongSelf->viewController viewDidAppear: YES ];
1636+ }
16311637 }
16321638
16331639 if (completion)
@@ -2070,40 +2076,48 @@ - (void)dismissPopoverAnimated:(BOOL)aAnimated callDelegate:(BOOL)callDelegate o
20702076
20712077 __typeof__ (self) strongSelf = weakSelf;
20722078
2073- if (aAnimated )
2079+ if (strongSelf )
20742080 {
2075- [UIView animateWithDuration: duration animations: ^{
2076- __typeof__ (self) strongSelf = weakSelf;
2077- strongSelf->overlayView .alpha = 0 ;
2078- } completion: ^(BOOL finished) {
2079- __typeof__ (self) strongSelf = weakSelf;
2080-
2081+ if (aAnimated)
2082+ {
2083+ [UIView animateWithDuration: duration animations: ^{
2084+ __typeof__ (self) strongSelf1 = weakSelf;
2085+ if (strongSelf1)
2086+ {
2087+ strongSelf1->overlayView .alpha = 0 ;
2088+ }
2089+ } completion: ^(BOOL finished1) {
2090+ __typeof__ (self) strongSelf1 = weakSelf;
2091+ if (strongSelf1)
2092+ {
2093+ [strongSelf1->containerView removeFromSuperview ];
2094+ strongSelf1->containerView = nil ;
2095+
2096+ [strongSelf1->overlayView removeFromSuperview ];
2097+ strongSelf1->overlayView = nil ;
2098+ }
2099+ }];
2100+ }
2101+ else
2102+ {
20812103 [strongSelf->containerView removeFromSuperview ];
20822104 strongSelf->containerView = nil ;
20832105
20842106 [strongSelf->overlayView removeFromSuperview ];
20852107 strongSelf->overlayView = nil ;
2086- }];
2087- }
2088- else
2089- {
2090- [strongSelf->containerView removeFromSuperview ];
2091- strongSelf->containerView = nil ;
2108+ }
20922109
2093- [strongSelf->overlayView removeFromSuperview ];
2094- strongSelf->overlayView = nil ;
2095- }
2096-
2097- if ([strongSelf->viewController isKindOfClass: [UINavigationController class ]] == NO )
2098- {
2099- [strongSelf->viewController viewDidDisappear: aAnimated];
2100- }
2101-
2102- if (callDelegate)
2103- {
2104- if (strongSelf->delegate && [strongSelf->delegate respondsToSelector: @selector (popoverControllerDidDismissPopover: )])
2110+ if ([strongSelf->viewController isKindOfClass: [UINavigationController class ]] == NO )
2111+ {
2112+ [strongSelf->viewController viewDidDisappear: aAnimated];
2113+ }
2114+
2115+ if (callDelegate)
21052116 {
2106- [strongSelf->delegate popoverControllerDidDismissPopover: strongSelf];
2117+ if (strongSelf->delegate && [strongSelf->delegate respondsToSelector: @selector (popoverControllerDidDismissPopover: )])
2118+ {
2119+ [strongSelf->delegate popoverControllerDidDismissPopover: strongSelf];
2120+ }
21072121 }
21082122 }
21092123 };
@@ -2140,16 +2154,19 @@ - (void)dismissPopoverAnimated:(BOOL)aAnimated callDelegate:(BOOL)callDelegate o
21402154 [UIView animateWithDuration: duration animations: ^{
21412155 __typeof__ (self) strongSelf = weakSelf;
21422156
2143- if ((style & WYPopoverAnimationOptionFade) == WYPopoverAnimationOptionFade )
2157+ if (strongSelf )
21442158 {
2145- strongSelf->containerView .alpha = 0 ;
2146- }
2147-
2148- if ((style & WYPopoverAnimationOptionScale) == WYPopoverAnimationOptionScale)
2149- {
2150- CGAffineTransform endTransform = [self transformTranslateForArrowDirection: strongSelf->containerView.arrowDirection];
2151- endTransform = CGAffineTransformScale (endTransform, 0.1 , 0.1 );
2152- strongSelf->containerView .transform = endTransform;
2159+ if ((style & WYPopoverAnimationOptionFade) == WYPopoverAnimationOptionFade)
2160+ {
2161+ strongSelf->containerView .alpha = 0 ;
2162+ }
2163+
2164+ if ((style & WYPopoverAnimationOptionScale) == WYPopoverAnimationOptionScale)
2165+ {
2166+ CGAffineTransform endTransform = [self transformTranslateForArrowDirection: strongSelf->containerView.arrowDirection];
2167+ endTransform = CGAffineTransformScale (endTransform, 0.1 , 0.1 );
2168+ strongSelf->containerView .transform = endTransform;
2169+ }
21532170 }
21542171
21552172 } completion: ^(BOOL finished) {
0 commit comments