UINavigationController详解与使用(一)添加UIBarButtonItem
2012.12.28
效果图:
[img]
[/img]
这次添加的导航条及上面的左右按钮,都是再代码中进行添加,并未使用xib文件进行界面设计。
一、新建一个Empty App工程:UINavigationControllerDemo
二、创建一个View Controller,命名为RootViewController:依次选择File——New——New File,默认勾上With XIB for user interface.
三、打开AppDelegate.h,向其中添加属性:
这里重点介绍下
UIBarButtonItem *leftButton = [[UIBarButtonItemalloc]initWithBarButtonSystemItem:UIBarButtonSystemItemActiontarget:selfaction:@selector(selectLeftAction:)];
UIBarButtonSystemItemAction的风格,这是系统自带的按钮风格,看下图,你不用一个个试验,你也知道想用那个item,如下图:
[img]
[/img]