iOS-ナビゲーションコントローラ全画面スライド

1762 ワード

ナビゲーションコントローラが戻ってきて、ネット上にはすでにオープンソースのFDFullscreenPopGestureがあり、画面自体のエッジも横滑りして戻ることができますが、自分が簡単にしたいときでもいいので、まずコントローラのi n t e r a c t i v e PopGestureRecognizerを取得し、ジェスチャーを取得するdelegate~は以下のようになります.
**2016-12-08 16:48:32.573FlyElephant[21021:320874] ****    ****:; target= )>>**
**2016-12-08 16:48:32.573 FlyElephant[21021:320874] ****    ****Target:<_uinavigationinteractivetransition:>**
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"FlyElephant";
    [self.navigationController.navigationBar setBarTintColor:[UIColor greenColor]];
    
    NSLog(@"    :%@",self.navigationController.interactivePopGestureRecognizer);
    NSLog(@"    Target:%@",self.navigationController.interactivePopGestureRecognizer.delegate);
    
    id target = self.navigationController.interactivePopGestureRecognizer.delegate;
    //         ,           target action  
    UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:target action:@selector(handleNavigationTransition:)];
    pan.delegate = self;
    //        view        
    [self.view addGestureRecognizer:pan];
    //              
    self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
    //          
    if (self.childViewControllers.count == 1) {
        //            ,          ,
        return NO;
    }
    return YES;
}