From 48942ba26b29b0552a6bbb12108e5bfe244e4dd5 Mon Sep 17 00:00:00 2001 From: Aleksey Smolsky Date: Tue, 24 Jul 2018 13:23:25 +0300 Subject: [PATCH 1/2] clear animation when flag is false --- MaterialControls/MaterialControls/MDRippleLayer.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MaterialControls/MaterialControls/MDRippleLayer.m b/MaterialControls/MaterialControls/MDRippleLayer.m index 5d6a50b..6eef4bc 100644 --- a/MaterialControls/MaterialControls/MDRippleLayer.m +++ b/MaterialControls/MaterialControls/MDRippleLayer.m @@ -144,6 +144,8 @@ - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag { } else { [self clearEffects]; } + } else { + [self clearEffects]; } } From b5b609dfecf09c6dd86ffc9c71fd8052ba091b02 Mon Sep 17 00:00:00 2001 From: Aleksey Smolsky Date: Mon, 29 Oct 2018 14:40:33 +0300 Subject: [PATCH 2/2] fix crash [UIPageViewController _flushViewController:animated:] --- .../MaterialControls/MDRippleLayer.m | 8 ++--- .../MaterialControls/MDTabBarViewController.m | 34 ++++++++++--------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/MaterialControls/MaterialControls/MDRippleLayer.m b/MaterialControls/MaterialControls/MDRippleLayer.m index 6eef4bc..c073540 100644 --- a/MaterialControls/MaterialControls/MDRippleLayer.m +++ b/MaterialControls/MaterialControls/MDRippleLayer.m @@ -133,9 +133,9 @@ - (void)removeFromSuperlayer { } - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag { - if (anim == [self animationForKey:@"opacityAnim"]) { - self.opacity = 0; - } else if (flag) { + if([[anim valueForKey:@"opacityAnim"] isEqual:@"opacity"]) { + self.opacity = 0; + } else if (flag) { if (_userIsHolding) { _effectIsRunning = false; if ([self.layerDelegate respondsToSelector:@selector(mdLayer:didFinishEffect:)]) { @@ -326,7 +326,7 @@ - (void)clearEffects { opacityAnim.removedOnCompletion = false; opacityAnim.fillMode = kCAFillModeForwards; opacityAnim.delegate = self; - + [opacityAnim setValue:@"opacity" forKey:@"opacityAnim"]; [self addAnimation:opacityAnim forKey:@"opacityAnim"]; } diff --git a/MaterialControls/MaterialControls/MDTabBarViewController.m b/MaterialControls/MaterialControls/MDTabBarViewController.m index 840bf32..d3b3d25 100644 --- a/MaterialControls/MaterialControls/MDTabBarViewController.m +++ b/MaterialControls/MaterialControls/MDTabBarViewController.m @@ -222,22 +222,24 @@ - (void)moveToPage:(NSUInteger)selectedIndex { __unsafe_unretained typeof(self) weakSelf = self; disableDragging = YES; pageController.view.userInteractionEnabled = NO; - [pageController - setViewControllers:@[ viewController ] - direction:animateDirection - animated:YES - completion:^(BOOL finished) { - weakSelf->disableDragging = NO; - weakSelf->pageController.view.userInteractionEnabled = YES; - weakSelf->lastIndex = selectedIndex; - - if ([weakSelf->_delegate - respondsToSelector:@selector(tabBarViewController: - didMoveToIndex:)]) { - [weakSelf->_delegate tabBarViewController:weakSelf - didMoveToIndex:selectedIndex]; - } - }]; + dispatch_async(dispatch_get_main_queue(), ^{ + [pageController + setViewControllers:@[ viewController ] + direction:animateDirection + animated:NO + completion:^(BOOL finished) { + weakSelf->disableDragging = NO; + weakSelf->pageController.view.userInteractionEnabled = YES; + weakSelf->lastIndex = selectedIndex; + + if ([weakSelf->_delegate + respondsToSelector:@selector(tabBarViewController: + didMoveToIndex:)]) { + [weakSelf->_delegate tabBarViewController:weakSelf + didMoveToIndex:selectedIndex]; + } + }]; + }); } #pragma mark - PageViewController Delegate