사용자 정의 되돌아오기 단추 후 되돌아오기 제스처가 효력을 상실하는 문제를 해결합니다

1449 단어
4
  • 사용자 정의 UINavigationController
  • @interface JKNavigationController () 
    

    4
  • viewDidLoad 재구성 방법
  •   - (void)viewDidLoad { 
            [super viewDidLoad];  
            //  self  
            __weak typeof (self) weakSelf = self; 
            if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
                self.interactivePopGestureRecognizer.delegate = weakSelf;
                self.delegate = weakSelf; 
            }
      }
    

    4
  • pushViewController 방법을 재구성합니다
  •   - (void)pushViewController:(UIViewController *)viewController 
                         animated:(BOOL)animated { 
            if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) { 
                self.interactivePopGestureRecognizer.enabled = NO; 
            }  
            [super pushViewController:viewController animated:animated];
    }
    

    4
  • UINavigationControllerDelegate를 실현하는 방법
  •   - (void)navigationController:(UINavigationController *)navigationController 
              didShowViewController:(UIViewController *)viewController 
                           animated:(BOOL)animated { 
            if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
                self.interactivePopGestureRecognizer.enabled = YES; 
            }
    }
    

    좋은 웹페이지 즐겨찾기