iOS 导航条(navigation)
来源:互联网 发布:自制淘宝摄影棚 编辑:程序博客网 时间:2024/05/21 11:18
1.初始化 self.window = [[[UIWindow alloc]initWithFrame:[[UIScreen mainScreen] bounds]]autorelease]; self.viewController = [[[ViewController alloc]initWithNibName:@"ViewController" bundle:nil]autorelease];
UINavigationController *nav =[[[UINavigationController alloc]initWithRootViewController:self.viewController]autorelease]; nav.navigationBar.barStyle =UIBarStyleBlack; self.window.rootViewController =nav;
[self.window makeKeyAndVisible]; return YES;
initWithFrame:CGRectMake(0.0f,0.0f, 120.0f,36.0f)] autorelease];
-(BOOL)application:(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
}
2.更改导航条上返回按钮的标题
UIBarButtonItem *barButtonItem =[[UIBarButtonItem alloc] init];
barButtonItem.title =@"buttonName";
self.navigationItem.backBarButtonItem =barButtonItem;
[barButtonItem release]
3.返回到上一个视图,返回根视图以及返回到任意视图
//返回到上一个视图,比如用户单击导航栏的Back按钮
[[self navigationController]popViewControllerAnimated:YES]
//返回到根视图
[[self navigationController]popToRootViewControllerAnimated:YES];
//返回到任意视图
[[self navigationController]popToViewController:destiationViewControlleranimated:YES];
4.添加自定义视图到导航条的标题栏
该代码添加一个自定义的UILabel,但也可以添加其他任意控件(或者视图),比如UIImageView,UISwitch等等。
self.navigationItem.titleView = [[[UILabelalloc]
self.title = @"Hello";
5.为导航添加新按钮
修改navigationItem可以为导航栏添加新按钮,如果要删除按钮,将该项指定为空值即可。下面代码是为导航栏添加右边按钮
self.navigationItem.rightBarButtonItem =[[[UIBarButtonItem alloc] initWithTitle:@"Action"style:UIBarButtonItemStylePlain target:selfaction:@selector(performAction:)] autorelease];
- iOS 导航条(navigation)
- IOS OC Navigation 导航条动态隐藏
- iOS发福利!导航条(Navigation Bar)素材PSD下载
- IOS开发 导航条…
- Android: Hide Navigation bar 隐藏导航条
- Android: Hide Navigation bar 隐藏导航条
- iOS学习笔记——导航栏(Navigation)
- ios自定义导航navigation,设置navigation的背景图,navigation左边按钮,以及navigation字体颜色
- iOS 更改导航条上返回按钮的标题
- iOS新闻导航结构 tabbar+navigation
- iOS开发Navigation 导航栏渐变
- Web Navigation(Web导航)
- JSF导航规则(Navigation)
- 自定义navigation(导航栏)
- iOS 在导航条上添加自定义的u…
- [iOS 自定义导航栏/导航条]隐藏系统导航条
- ios导航条添加按钮
- ios设置导航条背景图片
- 归档(-)
- IOS --- 对象归档
- 设计模式随笔
- [转]UITableViewController基本操…
- 自定义UITableViewCell
- iOS 导航条(navigation)
- iOS中UIScrollView属性
- iOS中ARC和非ARC混用
- 读取网络图片
- NetWorking(网络)
- UIAlertview的用法(弹出窗口)
- 如何隐藏键盘和文本框偏离
- iOS中使用GDataXML解析XML文…
- IOS中Json解析的四种方法