嗨朋友我想为 windows 基础开发一个应用程序加载页面的第一页然后在下一个视图之后我想添加 UitabbarController。我已经实现了这段代码。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
flag=1;
splash *objSplash=[[splash alloc]initWithNibName:@"splash" bundle:nil];
Home *placeholder1 = [[Home alloc] initWithNibName:@"Home" bundle:nil];
placeholder1.title=@"Home";
placeholder1.tabBarItem.image=[UIImage imageNamed:@"home1.png"];
shopHome *placeholder2 = [[shopHome alloc] initWithNibName:@"shopHome" bundle:nil];
placeholder2.title=@"Store";
placeholder2.tabBarItem.image=[UIImage imageNamed:@"Shop.png"];
Search1 *placeholder3 = [[Search1 alloc] initWithNibName:@"Search1" bundle:nil];
placeholder3.title=@"Search";
placeholder3.tabBarItem.image=[UIImage imageNamed:@"search2.png"];
info *placeholder4 = [[info alloc]initWithNibName:@"info" bundle:nil];
placeholder4.title=@"Info";
placeholder4.tabBarItem.image=[UIImage imageNamed:@"info1.png"];
CartView *placeholder5=[[CartView alloc]initWithNibName:@"CartView" bundle:nil];
placeholder5.title=@"Cart";
placeholder5.tabBarItem.image=[UIImage imageNamed:@"Cart.png"];
NSMutableArray *localViewControllersArray = [[NSMutableArray alloc] init];
UINavigationController *localNavController;
localNavController = [[UINavigationController alloc] initWithRootViewController:placeholder1];
localNavController.navigationBar.tintColor=[UIColor blackColor];
// Add navigation controller to the local vc array (1 of 2)
[localViewControllersArray addObject:localNavController];
[localNavController release];
localNavController = [[UINavigationController alloc] initWithRootViewController:placeholder2];
[localViewControllersArray addObject:localNavController];
[localNavController release];
localNavController = [[UINavigationController alloc] initWithRootViewController:placeholder3];
[localViewControllersArray addObject:localNavController];
[localNavController release];
if(flag==1)
{
localNavController = [[UINavigationController alloc] initWithRootViewController:placeholder5];
[localViewControllersArray addObject:localNavController];
[localNavController release];
}
localNavController = [[UINavigationController alloc] initWithRootViewController:placeholder4];
[localViewControllersArray addObject:localNavController];
[localNavController release];
tabBarController = [[UITabBarController alloc] init];
//tabBarController.viewControllers = [NSArray arrayWithObjects:placeholder1, placeholder2, placeholder3, placeholder4, nil];
tabBarController.viewControllers = localViewControllersArray;
//tabBarController.tintColor=[UIColor colorWithRed:160/256.0 green:82/256.0 blue:45/256.0 alpha:1.0];
//tabBarController.tabBar.backgroundColor=[UIColor colorWithRed:160/256.0 green:82/256.0 blue:45/256.0 alpha:1.0];
tabBarController.delegate=self;
[placeholder1 release];
[placeholder2 release];
[placeholder3 release];
[placeholder4 release];
[self.window addSubview:objSplash.view];
//[self.window addSubview:navigationController.view];
//[self.window addSubview:tabBarController.view];
[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(goToNext) userInfo:nil repeats:NO];
flag=1;
[self parsingData];
[window makeKeyAndVisible];
return YES;
}
-(void)goToNext
{
//[self.navigationController.view addSubview:tabBarController.view];
[self.window addSubview:tabBarController.view];
}