0

タブバーを使用していますが、そのコントローラーに移動してもタブバーが表示されません。

ここにタブバークラスのコードがあります

UIViewController * myTruckDept= [[NYTTruckDeparture alloc]initWithSiteName:self.siteNam andSiteDate:self.date];
UIViewController * myEditionStates = [[NYTEditionStats alloc] initWithSiteName:self.siteName andSiteDate:self.date];
UIViewController * myPagingData = [[NYTPagingData alloc] initWithSiteName:self.siteName andSiteDate:self.date];
UIViewController * myDownTimeLog = [[NYTDowntimeLog alloc] initWithSiteName:self.siteName andSiteDate:self.date];
UIViewController * myComments = [[NYTComments alloc] initWithSiteName:self.siteName andSiteDate:self.date];

NSArray *array = [[NSArray alloc] initWithObjects:myTruckDept, myEditionStates, myPagingData, myDownTimeLog, myComments, nil];

self.viewControllersArray = array;
[self.view addSubview:myTruckDept.view];
self.selectedViewController = myTruckDept;
self.myTabBar.selectedItem=self.myTruckDeptTabBarItem;

このView ControllerをNavigation Controllerにプッシュすると、ナビゲーションバーが非表示になっていないときにタブバーが表示され、ナビゲーションバーを非表示にしてツールバーを使用すると、下部のタブバーが表示されなくなりました。

事前に迅速な返信が必要です。

4

2 に答える 2

0

// UIViewController を定義する

UIViewController * myTruckDept= [[NYTTruckDeparture alloc]initWithSiteName:self.siteNam andSiteDate:self.date];
UIViewController * myEditionStates = [[NYTEditionStats alloc] initWithSiteName:self.siteName andSiteDate:self.date];
UIViewController * myPagingData = [[NYTPagingData alloc] initWithSiteName:self.siteName andSiteDate:self.date];
UIViewController * myDownTimeLog = [[NYTDowntimeLog alloc] initWithSiteName:self.siteName andSiteDate:self.date];
UIViewController * myComments = [[NYTComments alloc] initWithSiteName:self.siteName andSiteDate:self.date];

//UINavigation コントローラーにビューを追加する

UINavigationController * myTruckDeptNavC = [[UINavigationController alloc] initWithRootViewController: myTruckDept];
UINavigationController *topyummsNavC = [[UINavigationController alloc] initWithRootViewController: myEditionStates];
UINavigationController *myEditionStatesNavC = [[UINavigationController alloc] initWithRootViewController: myPagingData];
UINavigationController * myDownTimeLogNavC = [[UINavigationController alloc] initWithRootViewController: myDownTimeLog];
UINavigationController * myCommentsNavC = [[UINavigationController alloc] initWithRootViewController:myComments];

//ナビゲーションバーを隠す

myTruckDeptNavC.navigationBar.hidden = YES;
topyummsNavC .navigationBar.hidden = YES;
myEditionStatesNavC.navigationBar.hidden = YES;
myDownTimeLogNavC .navigationBar.hidden = YES;
myComments NavC.navigationBar.hidden = YES;

//タブバーを初期化し、コントローラを設定

self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects: myTruckDeptNavC, topyummsNavC, myEditionStatesNavC ,myDownTimeLogNavC , myCommentsNavC, nil];
self.tabBarController.delegate = self;

//UITable バーの表示

[self.window.rootViewController presentModalViewController:self.tabBarController animated:animated];

これが大いに役立つことを願っています。

于 2013-01-03T11:07:06.557 に答える
0

この Code For Creation を試してくださいCustom tabbarController。ここでは 2 つ作成しました。簡単に 4 つにできます。

詳細については、私の答えを確認してください: iOSコードの最適化

tabBar_Controller = [[UITabBarController alloc] init];
NSMutableArray *localControllersArray =[[NSMutableArray alloc]initWithCapacity:2];


firstViewController = [[FirstViewController alloc] initWithSiteName:self.siteNam andSiteDate:self.date];
nav = [[UINavigationController alloc] initWithRootViewController:firstViewController];
nav.tabBarItem.title = @"item1";
nav.navigationBar.barStyle = UIBarStyleBlack;
nav.navigationBar.hidden = YES;
[localControllersArray addObject:nav];
[self setNav:nil];

secondViewController = [[SecondViewController alloc] initWithSiteName:self.siteNam andSiteDate:self.date];
nav = [[UINavigationController alloc]initWithRootViewController:secondViewController];
nav.navigationBar.hidden = YES;
nav.tabBarItem.title = @"item2";
[localControllersArray addObject:nav];
[self setNav:nil];

tabBar_Controller.viewControllers = localControllersArray;
tabBar_Controller.delegate = self;
tabBar_Controller.selectedIndex = 0;
[self.window addSubview:tabBar_Controller.view];
于 2013-01-03T11:08:11.863 に答える