Skip to content

Commit

Permalink
fix transitionObj havent released
Browse files Browse the repository at this point in the history
  • Loading branch information
co42de committed Oct 27, 2018
1 parent c22ee49 commit b22e451
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ static CGFloat const ACST_SwipeShouldFinishDismissPercent = 0.5;
static CGFloat const ACST_SwipeFinishDismissDuration = 0.1 / ACST_SwipeShouldFinishDismissPercent;
static CGFloat const ACST_SwipeCancleDismissDuration = 0.3 / ACST_SwipeShouldFinishDismissPercent;

#import "UIViewController+ACSideslip.h"

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ - (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionC
} completion:^(BOOL finished) {
self.blackMask.hidden = YES;
self.shadowMask.hidden = YES;

[transitionContext completeTransition:![transitionContext transitionWasCancelled]];
[backVC ac_removeTransitionObject];
}];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,9 @@ - (void)finishTranslationAnimationWithDuration:(NSTimeInterval)duration
} completion:^(BOOL finished) {
self.blackMask.hidden = YES;
self.shadowMask.hidden = YES;

[self.context completeTransition:YES];
[backVC ac_removeTransitionObject];
}];

if (self.finishDelegate && [self.finishDelegate respondsToSelector:@selector(swipeInteractiveTransitionDidFinished)])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@

- (void)ac_sideslip:(UIViewController * __nonnull)newVC completion:(void (^ __nullable)(void))completion;

- (void)ac_removeTransitionObject;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,31 @@ - (void)ac_sideslip:(UIViewController * __nonnull)newVC completion:(void (^ __nu
[sideslipTransitionObject sideslip:newVC from:self completion:completion];
}

- (void)ac_removeTransitionObject {
ACSideslipTransition *sideslipTransitionObject = [self ac_sideslipTransitionObject];
if (sideslipTransitionObject) {
objc_setAssociatedObject(self,
kACSideslipTransitionObjectKey,
nil,
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
sideslipTransitionObject = nil;
}
}

#pragma mark - Associated Properties

- (ACSideslipTransition *)ac_sideslipTransitionObject {
ACSideslipTransition *sideslipTransitionObject = objc_getAssociatedObject(self, kACSideslipTransitionObjectKey);
return sideslipTransitionObject;
}

- (void)ac_setSideslipTransitionObject:(ACSideslipTransition *)sideslipTransitionObject {
objc_setAssociatedObject(self,
kACSideslipTransitionObjectKey,
sideslipTransitionObject,
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (ACSideslipTransition *)ac_sideslipTransitionObject {
ACSideslipTransition *sideslipTransitionObject = objc_getAssociatedObject(self, kACSideslipTransitionObjectKey);
return sideslipTransitionObject;
}


@end
5 changes: 5 additions & 0 deletions ACSideslipTransition/SecondViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ @interface SecondViewController () <ACSideslipSwipeInteractiveTransitionFinished

@implementation SecondViewController

- (void)dealloc
{
NSLog(@"dealloc SecondViewController");
}

#pragma mark - ACSideslipSwipeInteractiveTransitionFinishedDelegate

- (void)swipeInteractiveTransitionDidFinished
Expand Down

0 comments on commit b22e451

Please sign in to comment.