Black bar at the bottom in IOS6 instead UITabBarController - ios

I have two viewController (A,B), when I launch my app my root is a viewController A. He has an UitableView and an UITabBarController at the bottom. When I click in my UitableView I go to my viewController B.
My issue is that when I arrive in my viewController B, I have a black bar at the bottom of my view as if my UITabBarController stay, but I don't think it's that because I have the issue only on IOS 6.
And I don't want to see a UITabBarController in my viewController B, I want to have a simple view with a UiWebView but she doesn't go at the bottom.
In my viewController B in viewWillAppear I do [self._tabBarControllerArticle.tabBar setHidden:YES];
I have IOS 6/7 Deltas with Delta Y (20 or -20) with all components in my viewController B.
The result are good for IOS 7.
I don't know how can I resolve that.

When click on table cell call hideTabBar as given below
- (void)hideTabBar:(UITabBarController *) tabbarcontroller
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
}
}
[UIView commitAnimations];
}
- (void)showTabBar:(UITabBarController *) tabbarcontroller
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
NSLog(#"%#", view);
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
}
}
[UIView commitAnimations];
}
Show again when again come to the controller A again.

Related

hiding a non-translucent uitabbar [duplicate]

I have a question about iOS's UITabBarController's tab bar.
I'm using a UITabBarController to display a few views, but as I want the views to be displayed with as large a screen as possible. Is it possible to hide the tab bar so that it normally doesn't show, until the user touches the screen, then the tab bar will (with animation) show up at the bottom. Then, after a few seconds, if nothing is done, then the tab bar will again go away, so that the view going back to be full screen again?
This is how you show it
- (void)showTabBar:(UITabBarController *)tabbarcontroller
{
tabbarcontroller.tabBar.hidden = NO;
[UIView animateWithDuration:kAnimationInterval animations:^{
for (UIView *view in tabbarcontroller.view.subviews) {
if ([view isKindOfClass:[UITabBar class]]) {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y-49.f, view.frame.size.width, view.frame.size.height)];
}
else {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height-49.f)];
}
}
} completion:^(BOOL finished) {
//do smth after animation finishes
}];
}
... and this is how you hide it
- (void)hideTabBar:(UITabBarController *)tabbarcontroller
{
[UIView animateWithDuration:kAnimationInterval animations:^{
for (UIView *view in tabbarcontroller.view.subviews) {
if ([view isKindOfClass:[UITabBar class]]) {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y+49.f, view.frame.size.width, view.frame.size.height)];
}
else {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height+49.f)];
}
}
} completion:^(BOOL finished) {
//do smth after animation finishes
tabbarcontroller.tabBar.hidden = YES;
}];
}
With the accepted answer, on iOS 7 when you hide the tab bar and you show it again the size is wrong. This code gives a better result:
- (void) toggleTabBar: (UITabBar *)tabBar view: (UIView*) view {
tabBar.hidden = NO;
[UIView animateWithDuration:0.5 animations:^{
if (hiddenTabBar) {
tabBar.center = CGPointMake(tabBar.center.x, self.view.window.bounds.size.height-tabBar.bounds.size.height/2);
}
else {
tabBar.center = CGPointMake(tabBar.center.x, self.view.window.bounds.size.height+tabBar.bounds.size.height);
}
} completion:^(BOOL finished) {
hiddenTabBar = !hiddenTabBar;
tabBar.hidden = hiddenTabBar;
}];
}
Don't think that will work on Apple's UIGuidelines. The views you're using are drawn above the the tab bar, so if you fade it away, nothing will be there.
You could possibly make a small view with buttons in place of the tab bar that does what you want.

Unable to tap on UITabBar Frame area

In one of the view controller UITabBar has been set hidden and in the same place one CustomView with UITextField is added, But the entire CustomView is not taking any action.
If custom view is placed above the UITabBar it works fine. But I want to hide the Tab Bar in and place CustomView in the same frame.
I am using the below code to hide the Tab Bar
[self.tabBarController.tabBar setHidden:YES];
TaB Bar is added like this
[self.window addSubview:self.tabBarController.view];
Hiding the UITabBar does not still allow view below it to work. You will have to manually move the UITabBar when you want to hide and manually bring it back when you want to unhide if you want this functionality. The following code would work:
- (void)hideTabBar:(UITabBarController *) tabbarcontroller
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
}
}
[UIView commitAnimations];
}
If you want to move a particular tab bar button instead of the complete controller, you may have to do a little tweaking in the code.
Another option is to use hideBottomBarWhenPushed option like this
self.hidesBottomBarWhenPushed = true;
There is a property in UIViewController exactly for this reason - hidesBottomBarWhenPushed;
If you use storyboard then you can set this in view controller's attributes inspector in the storyboard - this is the best solution IMHO.
Like this:
If you don't use storyboard then you can set this property to YES in in viewDidLoad or in 'init' of the view controller that should hide the tab bar.
Something like this:
- (void)viewDidLoad {
[super viewDidLoad];
self.hidesBottomBarWhenPushed = YES;
}
I use the following code resize views when hiding/unhiding tabBar :
- (void)hideTabBar{
for (UIView *view in self.tabBarController.view.subviews) {
if ([view isKindOfClass:[UITabBar class]]) {
view.frame = CGRectMake(view.frame.origin.x,
[UIScreen mainScreen].bounds.size.height,
view.frame.size.width,
view.frame.size.height);
} else {
view.frame = CGRectMake(view.frame.origin.x,
view.frame.origin.y,
view.frame.size.width,
[UIScreen mainScreen].bounds.size.height);
}
}
}
- (void) showTabBar {
for (UIView *view in self.tabBarController.view.subviews) {
if ([view isKindOfClass:[UITabBar class]]) {
view.frame = CGRectMake(view.frame.origin.x,
[UIScreen mainScreen].bounds.size.height - 49,
view.frame.size.width,
view.frame.size.height);
} else {
view.frame = CGRectMake(view.frame.origin.x,
view.frame.origin.y,
view.frame.size.width,
[UIScreen mainScreen].bounds.size.height - 49);
}
}
}
Where 49 is the height of the tabBar.

Remove / Collapse bar at bottom of iOS simulator

I can successfully run tests on the iOS simulator using webdriver, the only concern that I have is that there is a bar at the bottom of the screen which prevents the whole screen from displaying. It is not causing tests to fail, just wondering if there is a way to remove/collapse it so that the whole screen displays.
If you are using Uitabbar then you can use:
[self hideTabBar:your tabbarcontroller];//call to hide the tabbar;
[self showTabBar:your tabbarcontroller];//call to show the tabbar;
- (void)hideTabBar:(UITabBarController *) myTabbarController
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *myView in myTabbarController.view.subviews)
{
if([myView isKindOfClass:[UITabBar class]])
{
[myView setFrame:CGRectMake(myView.frame.origin.x, 480,
myView.frame.size.width,
myView.frame.size.height)];
}
else
{
[myView setFrame:CGRectMake(myView.frame.origin.x,
myView.frame.origin.y,
myView.frame.size.width, 480)];
}
}
[UIView commitAnimations];
}
- (void)showTabBar:(UITabBarController *) tabbarcontroller
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width,
view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y,
view.frame.size.width, 431)];
}
}
[UIView commitAnimations];
}

show/hide the tabbar when needed from a view controller

i am new to iOS programming. i really need your help.
i have a login screen that takes me to a map (google API). on clicking any created annotation i want to load a tabbar with 2 views.
i searched and found out that i need to add the tabbar at the starting ie the appdelegate and show/hide the tabbar when needed.
so i made 2 functions to show and hide tabbar as
-(void)Load_tabBar{
[self.navigationController.view removeFromSuperview];
[self.window addSubview:tabBarController.view];
[self.window makeKeyWindow];}
-(void)remove_tabBar{
self.tabBarController.selectedIndex=0;
[self.tabBarController.view removeFromSuperview];
[self.window addSubview:navigationController.view];
[self.window makeKeyWindow];}
it did work when i call the Load_tabBar method and when i click back it calls remove_tabBar method. if i again call Load_tabBar method and back, it crashes giving error
-[UILayoutContainerView window]: message sent to deallocated instance 0x563b0b0
edited: PS : can i add tabbar view to a view controller and then push that view?
thnx
use this self.hidesBottomBarWhenPushed = YES;
This method definitely works. You just need to put it in the method BEFORE you push it, like this:
-actionThatPushTheViewController {
//create the view controller here, do some init.
//then:
theViewControllerToBePushed.hidesBottomBarWhenPushed = YES;
//push it here like this:
[self.navigationController pushViewController:theViewControllerToBePushed animated:YES];
I hope this two methods may help you,
- (void) hideTabBar:(UITabBarController *) tabbarcontroller {
int height = 480;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
for(UIView *view in tabbarcontroller.view.subviews) {
if([view isKindOfClass:[UITabBar class]]) {
[view setFrame:CGRectMake(view.frame.origin.x, height, view.frame.size.width, view.frame.size.height)];
}
else {
[view setFrame:CGRectMake(view.frame.origin.x,view.frame.origin.y, 320, 436)];
}
}
[UIView commitAnimations];
}
- (void) showTabBar:(UITabBarController *) tabbarcontroller {
int height = 480;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
for(UIView *view in tabbarcontroller.view.subviews) {
if([view isKindOfClass:[UITabBar class]]) {
[view setFrame:CGRectMake(view.frame.origin.x, height, view.frame.size.width, view.frame.size.height)];
}
else {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, height)];
}
}
[UIView commitAnimations];
}
Just put this two methods in AppDelegate class and call it where ever required as per you requirement.
if you want to hide it when pushed and show it when popped here is code:
if let viewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "SecondVC") as? SecondVC {
if let navigator = navigationController {
viewController.hidesBottomBarWhenPushed = true
navigator.pushViewController(viewController, animated: true)
}
}

iOS- How to Hide/Show UITabBarController's tab bar with animation?

I have a question about iOS's UITabBarController's tab bar.
I'm using a UITabBarController to display a few views, but as I want the views to be displayed with as large a screen as possible. Is it possible to hide the tab bar so that it normally doesn't show, until the user touches the screen, then the tab bar will (with animation) show up at the bottom. Then, after a few seconds, if nothing is done, then the tab bar will again go away, so that the view going back to be full screen again?
This is how you show it
- (void)showTabBar:(UITabBarController *)tabbarcontroller
{
tabbarcontroller.tabBar.hidden = NO;
[UIView animateWithDuration:kAnimationInterval animations:^{
for (UIView *view in tabbarcontroller.view.subviews) {
if ([view isKindOfClass:[UITabBar class]]) {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y-49.f, view.frame.size.width, view.frame.size.height)];
}
else {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height-49.f)];
}
}
} completion:^(BOOL finished) {
//do smth after animation finishes
}];
}
... and this is how you hide it
- (void)hideTabBar:(UITabBarController *)tabbarcontroller
{
[UIView animateWithDuration:kAnimationInterval animations:^{
for (UIView *view in tabbarcontroller.view.subviews) {
if ([view isKindOfClass:[UITabBar class]]) {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y+49.f, view.frame.size.width, view.frame.size.height)];
}
else {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height+49.f)];
}
}
} completion:^(BOOL finished) {
//do smth after animation finishes
tabbarcontroller.tabBar.hidden = YES;
}];
}
With the accepted answer, on iOS 7 when you hide the tab bar and you show it again the size is wrong. This code gives a better result:
- (void) toggleTabBar: (UITabBar *)tabBar view: (UIView*) view {
tabBar.hidden = NO;
[UIView animateWithDuration:0.5 animations:^{
if (hiddenTabBar) {
tabBar.center = CGPointMake(tabBar.center.x, self.view.window.bounds.size.height-tabBar.bounds.size.height/2);
}
else {
tabBar.center = CGPointMake(tabBar.center.x, self.view.window.bounds.size.height+tabBar.bounds.size.height);
}
} completion:^(BOOL finished) {
hiddenTabBar = !hiddenTabBar;
tabBar.hidden = hiddenTabBar;
}];
}
Don't think that will work on Apple's UIGuidelines. The views you're using are drawn above the the tab bar, so if you fade it away, nothing will be there.
You could possibly make a small view with buttons in place of the tab bar that does what you want.

Resources