OGeek|极客世界-中国程序员成长平台

标题: ios - 如何在 iOS9 中禁用 interactivePopGestureRecognizer 禁用 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 12:57
标题: ios - 如何在 iOS9 中禁用 interactivePopGestureRecognizer 禁用

我需要在我的应用程序中禁用 interactivePopGestureRecognizer,我做到了

- (void)viewDidAppearBOOL)animated
{

    [super viewDidAppear:animated];

    // Disable iOS 7 back gesture

 if ([self.navigationController respondsToSelectorselector(interactivePopGestureRecognizer)]) 
{

 self.navigationController.interactivePopGestureRecognizer.enabled = NO;

        self.navigationController.interactivePopGestureRecognizer.delegate = self;

    }
}


- (void)viewWillDisappearBOOL)animated
{
    [super viewWillDisappear:animated];

    // Enable iOS 7 back gesture

    if ([self.navigationController respondsToSelectorselector(interactivePopGestureRecognizer)])
 {

 self.navigationController.interactivePopGestureRecognizer.enabled = YES;

self.navigationController.interactivePopGestureRecognizer.delegate = nil;

 }
}


- (BOOL)gestureRecognizerShouldBeginUIGestureRecognizer *)gestureRecognizer

{

 return NO;
}

它适用于“iOS8”,我在“iOS9”上有一个问题。



Best Answer-推荐答案


如果你想全局禁用interactivePopGestureRecognizer,你可以在如下创建navigationController后禁用它。

UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:rootVC];
nav.interactivePopGestureRecognizer.enabled=NO;

关于ios - 如何在 iOS9 中禁用 interactivePopGestureRecognizer 禁用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34449037/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://jike.in/) Powered by Discuz! X3.4