指定页面页面导航隐藏并开启页面滑动返回
2017-04-19 16:14
141 查看
指定页面隐藏导航条只需要实现下面两个方法
这种方法隐藏导航条的同时系统的手势返回功能也会失效,如果想要手势返回的功能保留,有两种方案 。
一: 需要在 viewDidLoad方法中设置导航的 interactivePopGestureRecognizer 属性为YES 并设置 代理
这样虽然能实现页面的滑动返回功能,但也带来一个严重的bug -.-返回到导航的 root控制器时由于滑动返回仍然存在,如果在root页面做同样的滑动返回手势再次push到隐藏导航的页面就回卡在root页面。。。当然有解决方法
在rootvc 的viewDidApper方法里面把滑动返回手势关掉
- (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:YES animated:YES]; } - (void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; [self.navigationController setNavigationBarHidden:NO animated:YES]; }
这种方法隐藏导航条的同时系统的手势返回功能也会失效,如果想要手势返回的功能保留,有两种方案 。
一: 需要在 viewDidLoad方法中设置导航的 interactivePopGestureRecognizer 属性为YES 并设置 代理
- (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; self.navigationController.interactivePopGestureRecognizer.enabled = YES; // 手势 self.navigationController.interactivePopGestureRecognizer.delegate = nil; // Do any additional setup after loading the view. }
这样虽然能实现页面的滑动返回功能,但也带来一个严重的bug -.-返回到导航的 root控制器时由于滑动返回仍然存在,如果在root页面做同样的滑动返回手势再次push到隐藏导航的页面就回卡在root页面。。。当然有解决方法
在rootvc 的viewDidApper方法里面把滑动返回手势关掉
- (void)viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; self.navigationController.interactivePopGestureRecognizer.enabled = NO; }二: 在自定义导航控制器里实现如下代码
- (void)viewDidLoad { [super viewDidLoad]; self.delegate = self; self.popDelegate = self.interactivePopGestureRecognizer.delegate; } #pragma mark - UINavigationControllerDelegate - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated { if (viewController == self.viewControllers[0]) { self.interactivePopGestureRecognizer.delegate = self.popDelegate; }else { self.interactivePopGestureRecognizer.delegate = nil; } }
相关文章推荐
- 对类似Tab页面下的Listview滑动时,隐藏Tab导航
- 自己遇到的 导航控制器 push了好几层 让他一次返回到前面的指定页面 不一定是根页面
- iOS 导航返回到指定页面、一次返回到根试图或者让它一次性pop出几个页面
- 用jQuery实现的智能隐藏、滑动效果的返回顶部代码
- C# POST数据到指定url并返回结果页面内容
- javascript调用ajax页面返回指定内容
- 页面中指定内容的显示和隐藏
- Symbian 程序隐藏到后台,返回到主页面,按下特定的键值显示程序。
- HTTP协议中GET、POST和HEAD的介绍 2008-05-10 14:15 GET: 请求指定的页面信息,并返回实体主体。 HEAD: 只请求页面的首部。 POST: 请求服务器接受所指定的文
- 地址非xml后缀名的页面返回xml还需指定header中的type
- JS动态提示定时返回指定页面,相当于倒计时
- 创建具有固定导航功能的滑动单页面布局网站
- 在winform程序中打开IE,并导航到指定的页面。
- 类似网易新闻客户端 的滑动返回上个页面效果 MultiLayerNavigation
- 从页面元素上滑动到指定位置
- UINavigationController popToViewController直接返回指定级别页面
- C#读取Excel的指定页面的内容,并返回成一个DataTable
- servlet返回确认消息框后跳转到指定页面
- POST数据到指定url并返回结果页面内容
- 创建具有固定导航功能的滑动单页面布局网站