IOS系列——导航条UINavigationController的使用和不要xib文件的页面推

导航条 UINavigationController 在使用的时候,总是加在需要加导航条的前一个页面里面比如说有时候需要在第一个页面里面加导航条的时候,我们是在delegate里面来写,这个在之前的文章里面有写过,还有就是我们在后面的某一个页面需要用到导航条的时候,比如在首页我们不要导航条,但是在第二个页面里面需要的时候,我们要在首页推的时候这样写
- (IBAction)change:(id)sender {
    second *view = [[second alloc]init];
    UINavigationController *_nav = [[UINavigationController alloc]initWithRootViewController:view];
    [self presentViewController:_nav animated:NO completion:^{}];
}

这样的话,第二个页面就会有导航条了,而且上面的这些代码也包含了不要xib文件实现页面的推

- (IBAction)change:(id)sender {
    thirth *view = [[thirth alloc]initWithNibName:@"thirth" bundle:nil];
    [self.navigationController pushViewController:view animated:YES];
}

- (IBAction)change:(id)sender {
    fourth *view = [[fourth alloc]initWithNibName:@"fourth" bundle:nil];
    [self presentViewController:view animated:NO completion:^{}];
}

如果在后面需要用导航条,就可以这样一直往下推,中间不能断,断一次,如果还要使用导航条的话,就需要重新定义一个导航条
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值