我是新來這個iphone development.I已經創建了一個標籤欄應用程序,它由6個選項卡 這是對標籤欄控制器創作appdelegaate文件didfinishlaunching如何隱藏標籤欄項目?
UIViewController *viewController1 = [[[cardsAvailable1 alloc]
initWithNibName:@"cardsAvailable1" bundle:nil] autorelease];
UIViewController *viewController2 = [[[fetchcard1 alloc]
initWithNibName:@"fetchcard1" bundle:nil] autorelease];
UIViewController *viewController3 = [[[registration alloc]
initWithNibName:@"registration" bundle:nil] autorelease];
UIViewController *viewController4 = [[[logintab alloc]
initWithNibName:@"logintab" bundle:nil] autorelease];
UIViewController *viewController5 = [[[registration alloc]
initWithNibName:@"logout" bundle:nil] autorelease];
UIViewController *viewController6 = [[[logintab alloc]
initWithNibName:@"myprofile" bundle:nil] autorelease];
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:
[[[UINavigationController alloc] initWithRootViewController:viewController1] autorelease],
[[[UINavigationController alloc] initWithRootViewController:viewController2] autorelease],
[[[UINavigationController alloc] initWithRootViewController:viewController3] autorelease],
[[[UINavigationController alloc] initWithRootViewController:viewController4] autorelease],
[[[UINavigationController alloc] initWithRootViewController:viewController5] autorelease],
[[[UINavigationController alloc] initWithRootViewController:viewController6] autorelease],
nil];
self.tabBarController.selectedIndex = 3;
self.window.rootViewController = self.tabBarController;
[self.window addSubview:self.tabBarController.view];
[self.window makeKeyAndVisible];
我現在的問題是之後的代碼人是登錄即點擊登錄頁面上的登錄按鈕,我想隱藏兩個標籤欄項目,即註冊頁面和登錄頁面,需要帶註銷頁面和myprofile頁面的標籤欄包括取卡和卡可用任何人都可以建議我採取這種方法嗎?
我認爲這不會工作,因爲我創建的標籤欄應用程序,以便在標籤欄控制器代碼寫在委託文件didfinishlaunching.then我如何能在另一個類文件中使用此代碼。你能告訴我該把代碼放在哪裏嗎? – user1288402 2012-04-04 05:03:33
您需要在其他類文件中引用標籤欄控制器。例如,您可以使標籤欄控制器成爲應用程序代理的一個屬性,並在那裏訪問它。另一種方法是在應用程序委託中添加一個方法,您的類可以執行並刪除該選項卡。 – 2012-04-04 05:13:14
我已經更新了我的回覆中的代碼,以便爲您的特定應用程序工作。 – 2012-04-04 05:17:02