ios7手势操作
时间:2023-12-27 03:22:52 编辑:篆字君 来源:篆体字网
1 @interface CBNavigationController : UINavigationController2 @end 3 4 @implementation CBNavigationController 5 6 - (void)viewDidLoad 7 { 8 __weak CBNavigationController *weakSelf= self; 9 10 if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)])11 {12 self.interactivePopGestureRecognizer.delegate= weakSelf;13 self.delegate= weakSelf;14 }15 }16 17 // Hijack the push method to disable the gesture18 19 - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated20 {21 if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)])22 self.interactivePopGestureRecognizer.enabled= NO;23 24 [super pushViewController:viewController animated:animated];25 }26 27 #pragma mark UINavigationControllerDelegate28 29 - (void)navigationController:(UINavigationController *)navigationController30 didShowViewController:(UIViewController *)viewController31 animated:(BOOL)animate32 {33 // Enable the gesture again once the new controller is shown34 35 if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)])36 self.interactivePopGestureRecognizer.enabled= YES;37 }38 39 40 @end