//************************************************************ -10 UINavigationController 导航控制器
// 代码的方式 OneViewController.m中 继承类UIViewController 点中xib
-(void)viewDidLoad
{
[super viewDidLoad];
//设置标题:
//方法一 self.navigationItem.title =@"标题";
//方法二 self.title =@"标题”;
//添加导航栏左边按钮
UIBarButtonItem *cameraItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:nil action:nil];
UIBarButtonItem *composeItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemcompose target:nil action:nil];
//左边
self.navigationItem.leftBarButtonItems=@[cameraItem,composeItem];
//右边
self.navigationItem.rightBarButtonItems= cameraItem;
}
// storyboard 方式创建导航控制器的步骤
(1)添加 Navigation Controller (导航控制器到Main storyboard 旁边) 删除右边的Root View Controller
(2) Navigation Controller 里选中 Is Initial View Controller
(3)右键Navigation Controller 把root view Controller 连线到 View Controller
(4) //进入下一个控制器
(5)在 VIew Controller 中添加一个button 再创建一个新的View Controller control连线他们两个 连接push( 新方法是连线show 但是没有nevigation Item 需要自己拉控件到标题中 才能设置标题)
(6)如果要 在新view 中 添加button 以点击回到 返回上一个控制器 只能通过代码的方式 创建一个类 继承UIViewController
连线.m文件
-(IBAction)back
{
//返回上一个控制器
[self.navigationController popViewControllerAnimation:YES];
}
(6)//设置标题 点击 navigation Item 中 双击 输入标题名称
(7)// 设置导航栏左右两边的按钮 查找控件 Item 拉出控件中导航栏中 设置它的样式Bordered
(8)// 设置nevigation Item 中的Title 就可以修改标题 BackButton 设置返回 下一个视图中的返回按钮
IOS学习之——导航控制器 UINavigationController
最新推荐文章于 2024-06-03 20:57:32 发布