123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- #import "CTAssetsNavigationController.h"
- @interface CTAssetsNavigationController ()<UIGestureRecognizerDelegate, UINavigationControllerDelegate>
- @end
- @implementation CTAssetsNavigationController
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- __weak CTAssetsNavigationController<UIGestureRecognizerDelegate> *weakSelf = self;
-
- if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)])
- {
- self.interactivePopGestureRecognizer.delegate = weakSelf;
-
- self.delegate = weakSelf;
- }
-
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
-
- }
- - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
- {
-
- if ( [self respondsToSelector:@selector(interactivePopGestureRecognizer)] && animated == YES )
- {
- self.interactivePopGestureRecognizer.enabled = NO;
- }
-
- [super pushViewController:viewController animated:animated];
-
- }
- - (NSArray *)popToRootViewControllerAnimated:(BOOL)animated
- {
- if ( [self respondsToSelector:@selector(interactivePopGestureRecognizer)] && animated == YES )
- {
- self.interactivePopGestureRecognizer.enabled = NO;
- }
-
- return [super popToRootViewControllerAnimated:animated];
-
- }
- - (NSArray *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated
- {
- if( [self respondsToSelector:@selector(interactivePopGestureRecognizer)] )
- {
- self.interactivePopGestureRecognizer.enabled = NO;
- }
-
- return [super popToViewController:viewController animated:animated];
-
- }
- #pragma mark UINavigationControllerDelegate
- - (void)navigationController:(UINavigationController *)navigationController
- didShowViewController:(UIViewController *)viewController
- animated:(BOOL)animate
- {
- if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)])
- {
- self.interactivePopGestureRecognizer.enabled = YES;
- }
- }
- - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
- {
-
- if ( gestureRecognizer == self.interactivePopGestureRecognizer )
- {
- if ( self.viewControllers.count < 2 || self.visibleViewController == self.viewControllers[0] )
- {
- return NO;
- }
- }
-
- return YES;
- }
- @end
|