Hide the tab bar in a tab bar application - objective-c

I have created a new project from the template:
IPhoneOS>Application>Tab Bar Application.
I get two tabs.
How can I make the second become a full screen hiding the tab bar and even the status bar?
I tried to check the "Wants Full screen" - but it didn't help.
(Much less important... When I do get a full screen I do I get back?)
Please give me a simple code/guidelines or a reference to them, cause I'm a beginner - and Me and the compiler got too many issues to make things worse
Thanks
Asaf

To hide the tab bar you can use hidesBottomBarWhenPushed. For instance:
MyController *myController = [[MyController alloc]init];
myController.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:myController animated:YES];
[myController release];
To hide the status bar you can use:
[[UIApplication sharedApplication] setStatusBarHidden:YES];
To hide the nav bar you can use:
self.navigationController.navigationBarHidden = YES;

You can just use:
//Navigation bar:
self.navigationController.navigationBarHidden = YES;
//Statusbar:
[[UIApplication sharedApplication] setStatusBarHidden:YES];
//Tabbar:
self.tabBarController.tabBar.hidden = YES;

Have you checked Modal View Controllers out?
http://developer.apple.com/iphone/library/featuredarticles/ViewControllerPGforiPhoneOS/ModalViewControllers/ModalViewControllers.html
Try the presentModalViewController:animated: method on your navigationController (instead of pushing a view controller)
[self.navigationController presentModalViewController:foo animated:YES];

Another way to accomplish this is by making the UITabBarController the rootViewController of a UINavigationController. Then when you pushViewControllerAnimated: the tab bar will slide away with the root view controller.

Related

presentViewController over TabBarController causes "attempt to present *VC on TabBarVC whose view is not in the window hierarchy"

My root view controller is a Tab Bar Controller loaded in the delegate. Each of the tabs is a table view controller. When the application is first loaded I want a login screen to popup via presentViewController, which I have in my viewDidLoad method of the Tab Bar Controller. It results in the window hierarchy error that I have read about - though none of the solutions have worked for me. I tried instead presenting the modal view in the viewDidLoad method of the first tab but this resulted in the same error.
In my tab bar view controller in viewDidLoad, my code is:
CLLoginViewController *loginVC = [[CLLoginViewController alloc] init];
loginVC.delegate = self;
[self.view addSubview:loginVC.view];
[self presentViewController:loginVC animated:NO completion:nil];
Your question is quite vague but what i have understood, You want to present a login screen before the tabController is loaded.
So a better way would be, In your AppDelegate when setting rootViewController of window, do something like this
if([[NSUserDefaults standardUserDefaults] boolForKey:#"showTabBar"]){
self.window.rootViewController = tabBarControllerObject; //TabBarView is loaded
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:#"showTabBar"];
}
else{
self.window.rootViewController = tabBarControllerObject; //Login Screen is loaded for first time.
}
Hope this helps

PresentViewController with Tabbar and Navigationbar iOS

I am presenting a view controller class using custom navigation bar as follow:
CreateShiftRosterEventViewController *objDetailView = [[CreateShiftRosterEventViewController alloc] initWithNibName:#"CreateShiftRosterEventViewController" bundle:nil];
CustomNavigationViewController *navcont = [[CustomNavigationViewController alloc] initWithRootViewController:objDetailView];
// Set the user default to 1 to support landscape orientation also for next view
[[NSUserDefaults standardUserDefaults] setInteger:0 forKey:#"orientationView"];
[self presentViewController:navcont animated:YES completion:nil];
[objDetailView release];objDetailView = nil;
[navcont release];navcont=nil;
but it hides tab bar at CreateShiftRosterEventViewController class.
Can anyone please help me, what is wrong?
You have created navigationcontroller but you cann't add on view. This is the reason to hide.
You might have added the tab bar, but its not visible because of its autoresize setting. It must be aligned towards bottom of the screen.
You can find the screen shot attached below.

Hide FBFriendPickerViewController navbar when pushing onto UINavigationController

Presenting an instance of FBFriendPickerViewController using presentViewController:animated:completion: is pretty straightforward and the class seems like it is meant for that use case. However, I want to push an instance of FBFriendPickerViewController onto an instance of UINavigationController using pushViewController:animated:.
Consider the following code as an example:
self.fbFriendPickerController = [[FBFriendPickerViewController alloc] init];
self.fbFriendPickerController.hidesBottomBarWhenPushed = YES;
// configure stuff
[[self navigationController] pushViewController:self.fbFriendPickerController animated:YES];
However, the problem is that the instance of FBFriendPickerViewController already has a top navigation bar. When pushed onto a UINavigationController, this results in two top navigation bars stacked vertically, as you can see in the screenshot below.
One solution would be to hide the top nav bar of the UINavigationController, but that creates an awkward transition and there is no back button. Any thoughts on the best way to keep the UINavigationController top nav bar but the hide the FBFriendPickerViewController top nav bar?
After looking through the Facebook iOS SDK source code on Github, I figured this out. FBFriendPickerViewController is a subclass of FBViewController. If you set the doneButton and cancelButton properties of any FBViewController to nil, FBViewController will remove the top navigation bar. As a result, the following code works:
self.fbFriendPickerController = [[FBFriendPickerViewController alloc] init];
self.fbFriendPickerController.hidesBottomBarWhenPushed = YES;
self.fbFriendPickerController.doneButton = nil;
self.fbFriendPickerController.cancelButton = nil;
// configure stuff
[[self navigationController] pushViewController:self.fbFriendPickerController animated:YES];

Hide status bar for entire app

I create views programmatically. To hide status bar in view I use
[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO];
in viewDidload method. The problem is every view have to implement the code above to be status bar hidden. Is there a way (programmatically) to set status bar hidden just in one place in the app so entire app to be without the status bar ?
I have tried to add this in AppDelegate, but it doesn't work.
Open your app plist file MyApp-Info.plist and add a row with the Status bar is initially hidden and the YES value.
EDIT:
If you want to do it programmatically, add this in your ApplicationDidFinishLaunching :
[UIApplication sharedApplication].statusBarHidden = YES;
If you are targeting the devices with iOS > 3.2, then use the following code in application:didFinishLaunchingWithOptions: method in AppDelegate class.
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
just put key "Status bar is initially hidden" as YES in Info.plist file.
you will get hide status bar throughout the application.
If you want to do it by problematically, then just put this code in Appdelegate.m file of your project.
[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO];
Instead of creating new views based on UIView, subclass UIView (we can call it SummercView) and add a viewDidLoad method to it that looks like:
- (void) viewDidLoad
{
[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO];
[super viewDidLoad];
}
And then in your xib or storyboard files, set the views where you want to hide the status bar to use SummercView instead of UIView.
And of course #Aadhira's answer is good, too. +1 to him/her.
Couldn't you create a view class which did this in viewDidLoad, and have your views be subclasses of it? They'd still each have to hide the status bar, but at least you wouldn't have to duplicate the code in each subclass.

Objective-c How properly mange multiple views and controllers

I have an aplication which initially there's a TabBarController, each tab is a ViewController and every one has a button which calls other controllers.
So how am I supose to structure this? Having one main rootviewController (if so, how?)? Or calling in the appdelegate only the tabBarController and in each the viewControllers inside the tab call the other controllers?
What's the best way so I can advance, go back and transition views nimbly?
Don't know if I made myself clear...
Thanks guys.
Generally you will start with the Template called "Tab Bar Application" and as of Xcode 4 starts by loading the MainWindow Nib, which hold a tab bar and the tab bar is set up in IB to have 2 view controllers, called "FirstViewController", and "SecondViewController"...
You can follow that pattern if it suites you, otherwise you may want to start with a view based application and add your own tab bar. I personally find it to be easier to control the tab bar, through the UITabBarDelegate, especially if you plan to do anything slightly esoteric.
Edit:
Basically one of two ways, if you plan to load a Navigation controller stack, or a single modal view.
1)
ThirdViewController * controller = [[ThirdViewController alloc] initWithNibName:#"ThirdViewController" bundle:nil];
UINavigationController * myNavigationController = [[UINavigationController alloc] initWithRootViewController:controller];
[self presentModalViewController:myNavigationController animated:YES];
[controller release];
[myNavigationController release];
2)
ThirdViewController * controller = [[ThirdViewController alloc] initWithNibName:#"ThirdViewController" bundle:nil];
[self presentModalViewController:controller animated:YES];
[controller release];
either way get back to the Tab environment by calling the following on the view controller that is calling present modal.
[self
dismissModalViewControllerAnimated:YES];