导航条
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:^{}];
}
如果在后面需要用导航条,就可以这样一直往下推,中间不能断,断一次,如果还要使用导航条的话,就需要重新定义一个导航条