Reputation: 357
I have a tab bar application. Here's launching code
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
[self.window makeKeyAndVisible];
self.tabBarController=[[UITabBarController alloc] init];
StartViewController *startViewController=[[StartViewController alloc] initWithNibName:@"StartViewController" bundle:nil];
NavRootViewController *navRootViewController=[[NavRootViewController alloc] initWithNavControllerWithSubViewController:startViewController];
HelpViewController *helpViewController=[[HelpViewController alloc] initWithNibName:@"HelpViewController" bundle:nil];
SettingsViewController *settingsViewController=[[SettingsViewController alloc] initWithNibName:@"SettingsViewController" bundle:nil];
AboutUsViewController *aboutUsViewController=[[AboutUsViewController alloc] initWithNibName:@"AboutUsViewController" bundle:nil];
[self.tabBarController setViewControllers:[NSArray arrayWithObjects: navRootViewController, helpViewController, settingsViewController, aboutUsViewController, nil]];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
self.window.backgroundColor = [UIColor whiteColor];
self.window.rootViewController=self.tabBarController;
Application launched with 4 tab bar tabs. This action is called after user presses start button in the first tab's navigation controller's root view controller
-(IBAction)startPressed:(id)sender
{
NSLog(@"startPressed: called");
RootViewController *vController=[[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
[self.navigationController pushViewController:vController animated:YES];
}
This works fine but I need to hide tab bar for my RootViewController
property hidesBottomBarWhenPushed
does not work.
Help me please, how can it be done?
Upvotes: 0
Views: 4856
Reputation: 553
UIViewController *nextViewController = [[UIViewController alloc] initWithNibName:@"NextViewController" bundle:[NSBundle mainBundle]];
// hide UITabbarController
nextViewController.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:nextViewController animated:YES];
[nextViewController release];
Upvotes: 1
Reputation: 12617
I hope this helps you:
- (void)viewWillAppear: (BOOL)animated
{
self.hidesBottomBarWhenPushed = YES;
}
Upvotes: 6
Reputation: 357
Solved using this code:
-(IBAction)startPressed:(id)sender
{
NSLog(@"startPressed: called");
RootViewController *vController=[[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
UINavigationController *navController=[[UINavigationController alloc] initWithRootViewController:vController];
[vController setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[((AppDelegate *)[UIApplication sharedApplication].delegate).tabBarController presentModalViewController:navController animated:YES];
}
Thanks to @iPhone Developer
Upvotes: 1
Reputation: 1581
Yea you have to add the modalview on window not on the viewcontroller of tabBar.
Try something like.. make an object of AppDelegate like:
AppDelegate *appDelegate=[[UIApplication sharedApplication]delegate];
then in next line add
[appDelegate.window.rootviewcontroller.view presentModalViewController:vController animated:YES];
or add your code [self presentModalViewController:vController animated:YES]
in the viewDidAppear of the firstviewcontroller of tabBar.
What did you do to solve the problem??I would like to know that also.
Upvotes: 1
Reputation: 6803
If you don't want the main view to show the tab bar, you shouldn't be pushing it onto the navigation controller. Doing this causes the application to assume that this new controller is part of the navigation hierarchy. What is probably the best solution is to start your application on the RootViewController, and then present the navigation controller modally. When you're done with the navigation controller, have it call dismissModalViewController
on itself.
Upvotes: 1