tab bar swipe interactive transition
This commit is contained in:
parent
b6dda095d6
commit
92fb1d96b8
@ -867,6 +867,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (id <UIViewControllerInteractiveTransitioning>)navigationController:(UINavigationController *)navigationController interactionControllerForAnimationController:(id<UIViewControllerAnimatedTransitioning>)animationController {
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(navigationController:interactionControllerForAnimationController:)]) {
|
||||
return [self.delegate navigationController:navigationController interactionControllerForAnimationController:animationController];
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewController:(UIViewController *)presentingViewController willPresentViewController:(UIViewController *)presentedViewController {
|
||||
|
||||
if ([self.delegate respondsToSelector:@selector(viewController:willPresentViewController:)]) {
|
||||
|
||||
@ -193,6 +193,8 @@
|
||||
|
||||
MVMCoreNavigationObject *navigationObject = [[MVMCoreNavigationObject alloc] initWithViewController:viewController navigationController:navigationController viewControllers:nil animated:animated tryToReplaceFirst:replaceInStack navigationType:NavigationTypeReplaceTop];
|
||||
[self startNavigationWithNavigationObject:navigationObject delegate:delegate completionHandler:completionBlock];
|
||||
|
||||
|
||||
}
|
||||
|
||||
- (void)replaceAfterRoot:(nonnull UIViewController *)viewController navigationController:(nullable UINavigationController *)navigationController animated:(BOOL)animated delegate:(nullable NSObject<MVMCorePresentationDelegateProtocol>*)delegate replaceInStack:(BOOL)replaceInStack completionHandler:(nullable void (^)(void))completionBlock {
|
||||
|
||||
@ -106,7 +106,10 @@
|
||||
|
||||
// Replaces the current view controller.
|
||||
NSMutableArray *viewControllers = [NSMutableArray arrayWithArray:self.navigationObject.navigationController.viewControllers];
|
||||
[viewControllers replaceObjectAtIndex:([self.navigationObject.navigationController.viewControllers count] - 1) withObject:self.navigationObject.viewController];
|
||||
if (viewControllers.count > 1) {
|
||||
[viewControllers removeObjectAtIndex:0];
|
||||
}
|
||||
[viewControllers replaceObjectAtIndex:(viewControllers.count - 1) withObject:self.navigationObject.viewController];
|
||||
[self setViewControllers:viewControllers];
|
||||
} else {
|
||||
|
||||
@ -240,10 +243,30 @@
|
||||
|
||||
- (nullable id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC {
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(navigationController:animationControllerForOperation:fromViewController:toViewController:)]) {
|
||||
return [self.delegate navigationController:navigationController animationControllerForOperation:operation fromViewController:fromVC toViewController:toVC];
|
||||
id animatedTransitioning = [self.delegate navigationController:navigationController animationControllerForOperation:operation fromViewController:fromVC toViewController:toVC];
|
||||
[animatedTransitioning addObserver:self forKeyPath:@"interactiveTransitionCanceled" options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew context:nil];
|
||||
return animatedTransitioning;
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (nullable id <UIViewControllerInteractiveTransitioning>)navigationController:(UINavigationController *)navigationController interactionControllerForAnimationController:(id<UIViewControllerAnimatedTransitioning>)animationController {
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(navigationController:interactionControllerForAnimationController:)]) {
|
||||
id interactiveTransitioning = [self.delegate navigationController:navigationController interactionControllerForAnimationController:animationController];
|
||||
return interactiveTransitioning;
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
|
||||
if ([keyPath isEqualToString:@"interactiveTransitionCanceled"]) {
|
||||
BOOL transitionStoped = ((NSNumber*)change[NSKeyValueChangeNewKey]).boolValue;
|
||||
if (transitionStoped) {
|
||||
[self markAsFinished];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -24,6 +24,9 @@
|
||||
fromViewController:(nonnull UIViewController *)fromVC
|
||||
toViewController:(nonnull UIViewController *)toVC NS_AVAILABLE_IOS(7_0);
|
||||
|
||||
- (nullable id <UIViewControllerInteractiveTransitioning>)navigationController:(nonnull UINavigationController *)navigationController
|
||||
interactionControllerForAnimationController:(nonnull id <UIViewControllerAnimatedTransitioning>) animationController NS_AVAILABLE_IOS(7_0);
|
||||
|
||||
// Called when a view controller will be presented on another view controller
|
||||
- (void)viewController:(nonnull UIViewController *)presentingViewController willPresentViewController:(nonnull UIViewController *)presentedViewController;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user