博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iOS -- 页面跳转present到一个NavigationController中
阅读量:6928 次
发布时间:2019-06-27

本文共 1811 字,大约阅读时间需要 6 分钟。

hot3.png

之前在项目时,也遇到该问题,当时是自己写了一个假的导航条,用View代替,现在找到一个更好的方法,不用傻傻的写一个View,直接上代码。

如图

A-->C

HYNCController *manageVC = [[HYNCController alloc] init];

manageVC.isNavPush = @"0";

HYNNavigationController *nav = [[HYNNavigationController alloc] initWithRootViewController:manageVC];
[self presentViewController:nav animated:NO completion:^{      }];

 

B-->C

 HYNCController *manageVC = [[HYNCController alloc] init];

 manageVC.isNavPush = @"1";

 [self.navigationController pushViewController:manageVC animated:YES];

C

.h  (nonatomic, copy) NSString *isNavPush;//没有导航条页面进入为0,其他为1

.m 返回按钮中

 if([_isNavPush isEqualToString:@"0"]){

        [self dismissViewControllerAnimated:NO completion:^{     }];
    
    }else{
        [self.navigationController popViewControllerAnimated:YES];
    }

- (void)viewWillAppear:(BOOL)animated

{
    [super viewWillAppear:animated];  
    //隐藏导航条
    self.navigationController.navigationBar.hidden = YES;

}

//上滑时 出现导航条

- (void)scrollViewDidScroll:(UIScrollView *)scrollView

{
    if(_tbView.contentOffset.y >40){
        self.navigationController.navigationBar.hidden = NO;
    }else{
        self.navigationController.navigationBar.hidden = YES;   
    }
}

//判断当前ViewController是push还是present方式显示的

//通过判断self有没有present方式显示的父视图presentingViewController- (void)senderClick:(UIButton *)sender {    if (self.presentingViewController) {        [self dismissViewControllerAnimated:YES completion:nil];    } else {        [self.navigationController popViewControllerAnimated:YES];    }}//通过判断self.navigationController.viewControllers的最后一个是否是当前控制器,或者self.navigationController.topViewController == self- (void)senderClick:(UIButton *)sender {    if (self.navigationController.topViewController == self) {        [self.navigationController popViewControllerAnimated:YES];    } else {        [self dismissViewControllerAnimated:YES completion:nil];    }}

 

转载于:https://my.oschina.net/huangyn/blog/886025

你可能感兴趣的文章
Android ListView和ListAdapter(附电话簿实例)
查看>>
Linux磁盘管理之LVM详解
查看>>
我的友情链接
查看>>
关于通达Oa的一些问题,raid,论坛
查看>>
我的友情链接
查看>>
WindowsXP系统中如何设置静态IP地址
查看>>
2017-11-06-构建之法:现代软件工程-阅读笔记
查看>>
bzoj 1221: [HNOI2001] 软件开发
查看>>
我的友情链接
查看>>
Linux下的文件及文件权限
查看>>
USACO 补完(TJ)计划
查看>>
重读IoC:从DI到CDI (上)
查看>>
MySQL 高可用架构
查看>>
Magento搜索产品结果不精准的问题
查看>>
php增删改查入门示例
查看>>
Java Socket
查看>>
nginx虚拟主机的配置
查看>>
linux中shell变量$#,$@,$0,$1,$2的含义解释
查看>>
IIS无法解析.json文件
查看>>
Squid配置详解+认证
查看>>