我是IOS的新手。在我的应用程序的主页中,有 3 个选项卡和 4 个按钮(使用导航控制器)。我在 appdelegate.m 中创建了一个 tabbarcontroller,如下所示:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
//Initializing the view controllers
UIViewController *disController1 = [[DisController1 alloc]initWithNibName:@"DisController1" bundle:nil];
UIViewController *viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
UIViewController *wishlistController = [[Wishlist alloc]initWithNibName:@"Wishlist" bundle:nil];
UIViewController *helpController = [[HelpController alloc]initWithNibName:@"HelpController" bundle:nil];
UIViewController *disController2 = [[DisController1 alloc]initWithNibName:@"DisController2" bundle:nil];
NSMutableArray *viewControllersArray = [[NSMutableArray alloc]init];
[viewControllersArray addObject:disController1];
[viewControllersArray addObject:viewController];
[viewControllersArray addObject:wishlistController];
[viewControllersArray addObject:helpController];
[viewControllersArray addObject:disController2];
//Initializing the tab bar controller
UIImage *img = [UIImage imageNamed:@"SES_tab bar"];
CGSize newSize = CGSizeMake(SCRN_WIDTH, TABHEIGHT);
Common *common = [[Common alloc]init];
UIImage *newImage = [common imageResize:img andResizeTo:newSize];
[common setTabBarColorandImage:newImage];
tabController = [[UITabBarController alloc]init];
tabController.viewControllers = [NSArray arrayWithObjects:disController1, viewController,wishlistController,helpController,disController2 ,nil];
tabController.selectedIndex = 1;
UITabBarItem *firstTab = [[tabController.tabBar items]objectAtIndex:0];
UITabBarItem *lastTab = [[tabController.tabBar items]objectAtIndex:4];
[firstTab setEnabled:NO];
[lastTab setEnabled:NO];
UINavigationController *navCtrl = [[UINavigationController alloc]initWithRootViewController:tabController];
//navCtrl.navigationBarHidden = NO;
//[navCtrl.navigationBar setBackgroundImage:img forBarMetrics:UIBarMetricsDefault];
[navCtrl.navigationBar setBarStyle:UIBarStyleBlackTranslucent ];
[navCtrl.navigationBar.topItem setTitle:@"Home"];
[self.window addSubview:tabController.view];
self.window.rootViewController = navCtrl;
[self.window makeKeyAndVisible];
return YES;
TabBar 适用于我的主页。但我的问题是当我单击按钮时,Tab 栏不会出现在新视图中。我该如何实施?