UINavigationController与UITabBarController的结合
到目前为止,iphone app的设计界面模式大概就三种:
1。上有导航栏、下有tab选项的app(此类app最多)
2。只有上面有导航栏的app(较少)
3。只有下面有tab选项的app(非常少,可能是无法展示太多的内容吧,个人觉得)
其中着重讲解一下第一种设计方式:
UIViewController,就那个界面框架,里面即含有navigation也含有tabbar
在创建此类app的时候,不要采取xcode中的UINavigation项目或是UITabBar类型的项目,直接创建view-base类的项目,然后在delegete的.m文件中添加----
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
CustomTabBarControler *tabbar =
[[CustomTabBarControler alloc]
init];//CustomTabBarControler是我们自己重新定义的UITabBarController类
self.tabbarController = tabbar;
[tabbar release];
// home
HomeViewControler *homeViewControler = [[HomeViewControler alloc]
init];
HomeNAVControler *homeNavControler = [[HomeNAVControler alloc]
initWithRootViewController:homeViewControler];
[homeViewControler release];
homeNavControler.tabBarItem = [[UITabBarItem
alloc]initWithTitle:@"Home" image:[UIImage
imageNamed:@"Btn_Home.png"] tag:0];
homeNavControler.navigationItem.title=@"Home";
homeNavControler.navigationBar.hidden=YES;
// search
UIViewController *searchViewControler;
//if([[UserService shareInstance] isUserLogin]){
// searchViewControler = [[OrderListViewController alloc]
init];
//}
//else
searchViewControler = [[TrackOrderViewController alloc]
init];
UINavigationController *searchNavControler =
[[UINavigationController alloc]
initWithRootViewController:searchViewControler];
[searchViewControler release];
searchNavControler.tabBarItem = [[UITabBarItem
alloc]initWithTitle:@"Track Order" image:[UIImage
imageNamed:@"Btn_Track.png"]
tag:1];
searchNavControler.navigationItem.title=@"Track Order";
searchNavControler.navigationBar.hidden=NO;
// cart
CartViewControler *cartViewControler = [[CartViewControler alloc]
init];
UINavigationController *cartNavControler = [[UINavigationController
alloc] initWithRootViewController:cartViewControler];