Search code examples
iosuinavigationcontrollerios9

How to disable swipe gesture of UINavigation Controller


In App Delegate:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];


    WalkThrough  *viewControllers=[[WalkThrough alloc]init];
    self.navigationController = [[UINavigationController alloc] initWithRootViewController:viewControllers];



[self.window setRootViewController:self.navigationController];
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
navigationController.navigationBar.hidden = YES;
self.window.backgroundColor = [UIColor clearColor];
[self.window makeKeyAndVisible];

return YES;
}

Solution

  • Try to disable interactivePopGestureRecognizer after [window makeKeyAndVisible].

    The key to the problem is that interactivePopGestureRecognizer property is nil until both two conditions are met:

    1. the navigationController is associated to the window

    2. the window become key and visible