@@ -32,7 +32,7 @@ of this software and associated documentation files (the "Software"), to deal
3232#endif
3333
3434#ifdef DEBUG
35- #define WY_LOG (fmt, ...) NSLog ((@" %s (%d ) : " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
35+ #define WY_LOG (fmt, ...) NSLog ((@" %s (%d ) : " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
3636#else
3737 #define WY_LOG (...)
3838#endif
@@ -511,17 +511,17 @@ - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
511511
512512- (BOOL )isPassthroughView : (UIView *)view
513513{
514- if (view == nil )
514+ if (view == nil )
515515 {
516- return NO ;
517- }
518-
519- if ([self .passthroughViews containsObject: view])
516+ return NO ;
517+ }
518+
519+ if ([self .passthroughViews containsObject: view])
520520 {
521- return YES ;
522- }
523-
524- return [self isPassthroughView: view.superview];
521+ return YES ;
522+ }
523+
524+ return [self isPassthroughView: view.superview];
525525}
526526
527527@end
@@ -1614,15 +1614,20 @@ - (void)presentPopoverFromRect:(CGRect)aRect
16141614 startTransform = CGAffineTransformScale (startTransform, 0.1 , 0.1 );
16151615 containerView.transform = startTransform;
16161616 }
1617+
1618+ __weak __typeof__ (self) weakSelf = self;
16171619
16181620 [UIView animateWithDuration: animationDuration animations: ^{
1619- overlayView.alpha = 1 ;
1620- containerView.alpha = 1 ;
1621- containerView.transform = endTransform;
1621+ __typeof__ (self) strongSelf = weakSelf;
1622+ strongSelf->overlayView .alpha = 1 ;
1623+ strongSelf->containerView .alpha = 1 ;
1624+ strongSelf->containerView .transform = endTransform;
16221625 } completion: ^(BOOL finished) {
1623- if ([viewController isKindOfClass: [UINavigationController class ]] == NO )
1626+ __typeof__ (self) strongSelf = weakSelf;
1627+
1628+ if ([strongSelf->viewController isKindOfClass: [UINavigationController class ]] == NO )
16241629 {
1625- [viewController viewDidAppear: YES ];
1630+ [strongSelf-> viewController viewDidAppear: YES ];
16261631 }
16271632
16281633 if (completion)
@@ -2050,34 +2055,41 @@ - (void)dismissPopoverAnimated:(BOOL)aAnimated callDelegate:(BOOL)callDelegate
20502055 if (overlayView == nil ) return ;
20512056
20522057 void (^completionBlock)(BOOL );
2053-
2058+
2059+ CGFloat duration = self.animationDuration ;
2060+ __weak __typeof__ (self) weakSelf = self;
2061+
20542062 completionBlock = ^(BOOL finished) {
2063+
2064+ __typeof__ (self) strongSelf = weakSelf;
20552065
20562066 if (aAnimated)
20572067 {
2058- [UIView animateWithDuration: animationDuration animations: ^{
2059- overlayView.alpha = 0 ;
2068+ [UIView animateWithDuration: duration animations: ^{
2069+ __typeof__ (self) strongSelf = weakSelf;
2070+ strongSelf->overlayView .alpha = 0 ;
20602071 } completion: ^(BOOL finished) {
2061- [overlayView removeFromSuperview ];
2062- overlayView = nil ;
2072+ __typeof__ (self) strongSelf = weakSelf;
2073+ [strongSelf->overlayView removeFromSuperview ];
2074+ strongSelf->overlayView = nil ;
20632075 }];
20642076 }
20652077 else
20662078 {
2067- [overlayView removeFromSuperview ];
2068- overlayView = nil ;
2079+ [strongSelf-> overlayView removeFromSuperview ];
2080+ strongSelf-> overlayView = nil ;
20692081 }
20702082
2071- if ([viewController isKindOfClass: [UINavigationController class ]] == NO )
2083+ if ([strongSelf-> viewController isKindOfClass: [UINavigationController class ]] == NO )
20722084 {
2073- [viewController viewDidDisappear: aAnimated];
2085+ [strongSelf-> viewController viewDidDisappear: aAnimated];
20742086 }
20752087
20762088 if (callDelegate)
20772089 {
2078- if (delegate && [delegate respondsToSelector: @selector (popoverControllerDidDismissPopover: )])
2090+ if (strongSelf-> delegate && [strongSelf-> delegate respondsToSelector: @selector (popoverControllerDidDismissPopover: )])
20792091 {
2080- [delegate popoverControllerDidDismissPopover: self ];
2092+ [strongSelf-> delegate popoverControllerDidDismissPopover: strongSelf ];
20812093 }
20822094 }
20832095 };
@@ -2111,8 +2123,11 @@ - (void)dismissPopoverAnimated:(BOOL)aAnimated callDelegate:(BOOL)callDelegate
21112123
21122124 if (aAnimated)
21132125 {
2114- [UIView animateWithDuration: animationDuration animations: ^{
2115- containerView.alpha = 0 ;
2126+ CGFloat duration = self.animationDuration ;
2127+
2128+ [UIView animateWithDuration: duration animations: ^{
2129+ __typeof__ (self) strongSelf = weakSelf;
2130+ strongSelf->containerView .alpha = 0 ;
21162131 } completion: ^(BOOL finished) {
21172132 completionBlock (finished);
21182133 }];
0 commit comments