您的位置:首页 > 移动开发 > IOS开发

iOS7返回手势的开启与禁用

2016-04-14 10:38 483 查看
1. 在有的时候,我们不需要手势返回功能,那么可以在页面中添加以下代码:  

[objc]
view plaincopyprint?

- (void)viewDidAppear:(BOOL)animated  

{  

    [super viewDidAppear:animated];  

  

    // 禁用 iOS7 返回手势  

    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {  

        self.navigationController.interactivePopGestureRecognizer.enabled = NO;  

    }  

}  

  

- (void)viewWillDisappear:(BOOL)animated  

{  

    [super viewWillDisappear:animated];  

  

    // 开启  

    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {  

        self.navigationController.interactivePopGestureRecognizer.enabled = YES;  

    }  

}  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: