I am new to this iphone development.I have created a tab bar application which consist of 6 tabs this is the code for the tab bar controller creation in appdelegaate file 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];
now my problem is after a person is login ie onclick the login button present in the login page i would like to hide the two tab bar item ie registration page and also login page and need to bring the logout page and myprofile page with the tab bar including fetch card and card avalable can any one suggest me a method to do that?
You can add and remove items on a tab bar by editing the array of view controllers for the tab bar.
NSMutableArray newArrayOfItems = [[NSMutableArray alloc] initWithArray:self.tabBarController items]];
[newArrayOfItems removeObjectAtIndex:indexOfUnneededItem];
[self.tabBarController setItems:newArrayOfItems animated:true];
[newArrayOfItems release];
In your example and in response to your comment the following code will work as long as you import your app delegate header.
NSMutableArray newArrayOfItems = [[NSMutableArray alloc] initWithArray: [[[UIApplication sharedApplication] delegate].tabBarController items]];
[newArrayOfItems removeObjectAtIndex:indexOfUnneededItem];
[[[UIApplication sharedApplication] delegate].tabBarController setItems:newArrayOfItems animated:true];
[newArrayOfItems release];
You can set the hidesBottomBarWhenPushed
property before pushing view controller. There is the sample code below:
LoginController *lc = [[LoginController alloc] initWithNibName:nil bundle:nil];
lc.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:lc animated:YES];
[lc release];