博客> 禁止系统自带的侧滑返回
禁止系统自带的侧滑返回
2017-09-20 18:20 评论:0 阅读:94 飞翔信念
禁止系统自带的侧滑返回

在需要关闭侧滑的界面添加关闭代码

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    self.navigationController.navigationBar.hidden=YES;

    // 禁用返回手势
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.enabled = NO;
    }

}

如果还需要在其他界面使用系统的侧滑返回,在viewwilldisappear里开启侧滑效果

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    // 开启返回手势
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    }
}
收藏
1
sina weixin mail 回到顶部