IOS 开启关闭右滑手势返回

来源:互联网 发布:数据接口协议 编辑:程序博客网 时间:2024/04/30 08:46
////  ViewController.m//////  Created by Fly on 16/5/2.//  Copyright © 2016年 mac. All rights reserved.// 右滑返回@interface YBRLoginViewController : UIViewController<UIGestureRecognizerDelegate>@end@implementation ViewController- (void)viewDidLoad {    [super viewDidLoad];    // Do any additional setup after loading the view.    self.navigationController.interactivePopGestureRecognizer.delegate = self;    self.navigationController.interactivePopGestureRecognizer.enabled = YES;}- (void)viewDidAppear:(BOOL)animated{    [super viewDidAppear:animated];    // 禁用返回手势    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {        self.navigationController.interactivePopGestureRecognizer.enabled = NO;    }}- (void)viewWillDisappear:(BOOL)animated{    [super viewWillDisappear:animated];    self.navigationController.navigationBarHidden = NO;    // 开启返回手势    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {        self.navigationController.interactivePopGestureRecognizer.enabled = YES;    }}@end

0 0