No Swipe Back when hiding Navigation Bar in UINavigationController

前端 未结 18 710
生来不讨喜
生来不讨喜 2020-12-04 06:34

I love the swipe pack thats inherited from embedding your views in a UINavigationController. Unfortunately i cannot seem to find a way to hide the Naviga

18条回答
  •  时光说笑
    2020-12-04 07:09

    You can subclass UINavigationController as following:

    @interface CustomNavigationController : UINavigationController
    
    @end
    

    Implementation:

    @implementation CustomNavigationController
    
    - (void)setNavigationBarHidden:(BOOL)hidden animated:(BOOL)animated {
        [super setNavigationBarHidden:hidden animated:animated];
        self.interactivePopGestureRecognizer.delegate = self;
    }
    
    - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
        if (self.viewControllers.count > 1) {
            return YES;
        }
        return NO;
    }
    
    @end
    

提交回复
热议问题