对UITabBarController的理解
来源:互联网 发布:simlab软件敏感性分析 编辑:程序博客网 时间:2024/06/06 17:42
理解:和UINavigationController一样,UITabBarController也可以控制多个页面导航。用户可以在多个视图控制器之间移动,并可以定制屏幕底部的选项卡栏。
UITabBarController是组建一系列的控制器,可以是UIViewController,UITableViewController,UINavigationController等,并将它们添加到选项卡栏,使每一个选项卡对应一个控制器。UINavigationController是以栈的形式将视图推入推出。UITabbarController一般作为appDelegate的根rootController使用。
分析图:
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) TabBarViewController * tabbarController;
.m中,AViewController *aController = [[AViewControlleralloc] init];
UINavigationController *nav = [[UINavigationControlleralloc] initWithRootViewController:aController];
//aController.title = @"aa";
BViewController *bController = [[BViewControlleralloc] init];
// bController.title = @"bb";
CViewController *cController = [[CViewControlleralloc] init];
// cController.title = @"cc";
DViewController *dController = [[DViewControlleralloc] init];
// dController.title = @"dd";
_tabbarController = [[TabBarViewControlleralloc] initWithNibName:@"TabBarViewController"bundle:nil];
_tabbarController.viewControllers = [NSArrayarrayWithObjects:nav,bController,cController,dController,nil];
//设置tabbar
//适合ios5以下
UIImageView *tabbarGroundImage = [[UIImageViewalloc] initWithImage:[UIImageimageNamed:@"mainbar_bg.png"]];
[tabbarGroundImage setFrame:CGRectMake(0,0,self.tabBar.frame.size.width,self.tabBar.frame.size.height)];
//ios5以下使用
[self.tabBar insertSubview:tabbarGroundImage atIndex:0];
[tabbarGroundImage release];
//适和ios5以上
[_tabbarController.tabBarsetBackgroundImage:[UIImageimageNamed:@"mainbar_bg.png"]];
UITabBarItem *aTabbar = [[UITabBarItemalloc] initWithTitle:nilimage:[UIImageimageNamed:@"mainbar_icon1_n.png"]tag:0];
[aTabbar setFinishedSelectedImage:[UIImageimageNamed:@"mainbar_icon1_d.png"]withFinishedUnselectedImage:[UIImageimageNamed:@"mainbar_icon1_h.png"]];
aController.tabBarItem = aTabbar;
[aTabbar release];
[aController release];
[nav release];
[bController release];
[cController release];
[dController release];
self.window.rootViewController =_tabbarController;
注:用TabbarController上的tabbar,backGroundImage和tabbarItem上的image都是不能改变大小的,所以对切图要求很高。
EViewController *eController = [[EViewControlleralloc] initWithNibName:@"EViewController"bundle:nil];
//在push之前加上这句话,放可管用。
eController.hidesBottomBarWhenPushed =YES;
[self.navigationControllerpushViewController:eController animated:YES];
[eController release];
- 对UITabBarController的理解
- 理解UITabBarController
- 改变UITabBarController的颜色
- 替代UITabBarController的方案
- UITabBarController的使用总结
- 坑爹的UITabBarController
- UITabBarController的基本使用方法
- UITabBarController的使用总结
- UITabBarController的使用总结
- UITabBarController的使用总结
- 改变UITabBarController的颜色
- UITabBarController的简单使用
- UITabBarController的实现方法
- UITabBarController注意的地方
- UITabBarController的使用心得
- ios--UITabBarController的用法
- 隐藏UITabBarController的tabBar
- 关于UITabBarController的使用
- STL 实现邻接表的存储与深搜广搜的完美结合不容错过啊!!!
- apche-mina2.0 简简单单搞定
- C++中单例模式的两种简单实现
- 手把手教你在pcduino上实现uspip--USB网络重定向
- JQuery实现点击div以外的位置隐藏该div
- 对UITabBarController的理解
- 【转】C#的模态对话框和非模态对话框
- jquery easyui datagrid 分页 详解
- 用ATL建立轻量级的COM对象(一)
- 大数的乘法 Multiply Strings
- GPRS模块发送短信
- Android设置界面及Preference使用 + 实现开启自启动 清理缓存 杀进程
- Most people stop at the Z — but not me!
- ubuntu apt-get dpkg-scanpackages 制作本地软件源