【导航】iOS自带的手势向左滑动返回

来源:互联网 发布:手机在线直播软件 编辑:程序博客网 时间:2024/05/07 16:09

首先, [self.windowsetRootViewController:是要有导航栏的];

实现可以左滑返回过程:

1. .h中遵守代理UIGestureRecognizerDelegate;

2. .m

    self.navigationController.interactivePopGestureRecognizer.delegate = self;        if([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)])    {        self.navigationController.interactivePopGestureRecognizer.enabled = YES;    }

注意:如果 self.navigationController.navigationBarHidden = NO;即导航没有隐藏时,

    if([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)])    {        self.navigationController.interactivePopGestureRecognizer.enabled = YES;    }
不用写代理也是可以的。直接一句就可以搞定。但是如果hidden为YES,就不行了。所以为了确保能向左滑动返回。应该写完整。

0 0
原创粉丝点击