New gesture - Swipe left to right - as shortcut for Back button in UINavigationController in old app

后端 未结 2 624
甜味超标
甜味超标 2021-01-06 00:07

iOS 7 sports a new gesture, swiping left to right across the screen as a shortcut for the Back button in a UINavigationController.

My app does not seem to be picking

2条回答
  •  心在旅途
    2021-01-06 00:47

    I have found the perfect solution for custom leftBarButtom problem

    Set the gesture delegate to the navigation controller

    you need to subclass UINavigationController and implement "UIGestureRecognizerDelegate" protocol in it, and add some code on viewDidLoad see the following code below

    CustomNavigationController.m

    @interface CBNavigationController : UINavigationController @end

    @implementation CBNavigationController

    • (void)viewDidLoad { __weak CBNavigationController *weakSelf = self;

      if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.interactivePopGestureRecognizer.delegate = weakSelf; } }

    @end

    and just inherit this class to your Navigation controller, it will work perfect.

提交回复
热议问题