12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- //
- // SGPagingViewPopGestureVC.m
- // SGPagingViewExample
- //
- // Created by kingsic on 2018/9/1.
- // Copyright © 2018年 kingsic. All rights reserved.
- //
- #import "SGPagingViewPopGestureVC.h"
- @interface SGPagingViewPopGestureVC () <UIGestureRecognizerDelegate> {
- id<UIGestureRecognizerDelegate> _delegate;
- }
- @end
- @implementation SGPagingViewPopGestureVC
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
-
- if (self.navigationController.viewControllers.count > 1) {
- // 记录系统返回手势的代理
- _delegate = self.navigationController.interactivePopGestureRecognizer.delegate;
- // 设置系统返回手势的代理为当前控制器
- self.navigationController.interactivePopGestureRecognizer.delegate = self;
- }
- }
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
-
- // 设置系统返回手势的代理为我们刚进入控制器的时候记录的系统的返回手势代理
- self.navigationController.interactivePopGestureRecognizer.delegate = _delegate;
- }
- #pragma mark - - UIGestureRecognizerDelegate
- - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
- return self.navigationController.childViewControllers.count > 1;
- }
- - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
- return self.navigationController.viewControllers.count > 1;
- }
- @end
|