Search code examples
iosgestureuipangesturerecognizer

How to enable full screen Pan back for UINavigationController


From iOS7 apple provide a way to pan back UINavigationController, but it can only be done by swipe form the edge of the screen. How to enable full screen pan back gesture?


Solution

  • I really spend a lot of time trying to solve this problem, at last I found the way. I just ask a question and answer it myself to share the solution here.

    Pls refer my blog to get more detail enter link description here

    Demo code:

    #import "TestNavigationController.h"
    
    @interface _UINavigationInteractiveTransition
    
    @end
    
    @interface UINavigationController(Custom)
    @property (strong, nonatomic) _UINavigationInteractiveTransition * _cachedInteractionController;
    
    @end
    
    @implementation TestNavigationController
    {
        UIPanGestureRecognizer *_p;
    }
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        NSLog(@"%@", self.interactivePopGestureRecognizer
              );
        _p = [[UIPanGestureRecognizer alloc]initWithTarget:self._cachedInteractionController action:@selector(handleNavigationTransition:)];
        NSLog(@"%@", self._cachedInteractionController);
        [self.view addGestureRecognizer:_p];
       } 
    @end
    

    EDIT NOTE: This exposes Private APIs.