Storyboard UITableViewController enable toolbar at bottom of screen - ios

I've created a storyboard based UITableViewController which is working and displaying data.
I now need to add a toolbar that will always be at the bottom of the screen. To do this I have added a toolbar button to my storyboard which has it positioned at the bottom of the screen.
I have added the following to my tableviewcontrollers viewWillAppear method
[self.navigationController setToolbarHidden:NO];
As described here
How to add a toolbar to the bottom of a UITableViewController in Storyboards?
However, I still get no toolbar...any ideas?

You want show toolbar in one view controller which placed in some navigation controller.
- (void)viewWillAppear:(BOOL)animated
{
//View will appear
[self.navigationController setToolbarHidden:NO animated:YES];
}
- (void)viewWillDisappear:(BOOL)animated
{
//View will disappear
[self.navigationController setToolbarHidden:YES animated:YES];
}

Related

how to hide navigation bar + toolbar and change tableView height on scroll

I've got a view controller embedded in a navigation controller with a toolbar attached under it so it has this style:
as you can see with my storyboard, i also have a container view with a tableviewcontroller inside:
on scroll, i need to hide the navigation bar which I've been able to do. The problem is, I have to also hide the toolbar that is under the nav bar as well as expand the height of the table view so that when the nav bar and toolbar both disappear, the table view can use the extra space.
I don't have perfect answer but try to use below code in cellForRowAtIndexPath
will help you..
you did not mentioned weather your code is in objective C/ Swift. I am providing you Both ::
Obj-C
[[self navigationController] setNavigationBarHidden:YES animated:YES];
Swift
self.navigationController().setNavigationBarHidden(true, animated: true)
For tabBar, If you want to hide tabBar with navigationBar use this thing..
Or use this for tabBar hide >
DetailViewController *detailViewController = [[DetailViewController alloc] init];
detailViewController.hidesBottomBarWhenPushed = YES;
[[self navigationController] pushViewController:detailViewController animated:YES];
[detailViewController release];

Popping View Controller causes Bar Button Item to disappear

I have two ViewControllers in my app. The first ViewController (say, ViewControllerOne) has a Bar Button Item that has a slide in TableView (irrelevant to the question). I have disabled the Navigation Bar in the second ViewController (say, ViewControllerTwo) and added a custom view and a Button. I have written the code to pop ViewControllerTwo in thee action of the button. But once it is popped, the BarButton Item in ViewControllerOne disappears.
here is the code I have written in ViewControllerTwo
[self.navigationController setNavigationBarHidden:YES animated:YES];
And
- (IBAction)backCustom:(id)sender
{
[self.navigationController popViewControllerAnimated:YES];
}
Any idea why the Bar Button Item would disappear because of this? I am sure this code is the reason because, When I remove it, it runs fine with the default NavigationBar.But I need a custom one for my project
in your first Viewcontroller add the following line
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:YES];
}

Navigation bar height changing on hide and unhide

In my application I have to show one screen with navigation bar and then by pushing another controller with no navigation bar.
When I come back I again want to show the navigation bar. But, my navigation bar is not visible with complete height.
I set the navigation bar with no translucent, and style opaque.
can you help me anyone.
this will hide and show navigation bar perfectly:
in first view controller implement:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
in pushed view controller:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:YES];
}
Show some code...
or try showing the navigation bar from the view controller you're coming back from just before you tell it to go back... Should avoid the issue. But suspect you're doing something else wrong.
Use this method:
In view controller where you want to hide navigation bar add the below code in viewWillAppear
[navigationController setNavigationBarHidden:YES];
So, if you are in some view controller:
In view controller where you want to show navigation bar add the below code in viewWillAppear
[self.navigationController setNavigationBarHidden:NO];

Wired black space under screen when pop to previous view controller using UINavigationController

I am using UINavigationController to direct some view controllers.In some view controller, I don't want to use UINavigationBar, but in some others i may use. Now I am try to pop one view controller using UINavigationBar to its previous one which hide UINavigationBar. But when poped, there is one wired black space under screen. After you rotate the screen, the space will disappear.
the normal view controller A should be like this:
when press the text button, a view controller B will be pushed, which is as followings:
when click back button on the navigation bar. A will come out.but there is a black space at the bottom.
If rotate the screen, the space will disappear. And also in A's - (void)viewWillAppear:(BOOL)animated method i hide the navigationbar and let the screen autorotate.
- (void)viewWillAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:YES animated:animated];
[super viewWillAppear:animated];
[self willAnimateRotationToInterfaceOrientation:[UIApplication sharedApplication].statusBarOrientation duration:0];
}
whats wrong with this situation? Any help will be appreciated.
I add setNavigationBarHidden: method in the back button action method. it works. If i add this method in viewWillDisappear: method or others, it seems it doesn't work. The navigation bar will have effect on next appear view controller. which means, there will be a black space in the next view controller in the navigation stack.
Finally, i add a action method for the back button and setNavigationBarHidden:YES in the method, which is as follows:
- (void)backBtnClicked:(id)sender
{
[self.navigationController popViewControllerAnimated:NO];
[self.navigationController setNavigationBarHidden:YES];
}

XCode/iOS: setToolbarHidden:animated creates new unwanted toolbar?

I'm trying to achieve something similar to user of this post:
Xcode/iOS: How to hide Navigation- AND ToolBar on scroll down?
I'm able to hide (or unhide using NO) the navigation bar successfully using the code:
[[self navigationController] setNavigationBarHidden:YES animated:YES];
However, when I attempt to hide the toolbar using the code:
[[self navigationController] setToolbarHidden:YES animated:YES];
Nothing happens. I then noticed when unhiding the toolbar that I received an additional blue toolbar that I didn't realize existed. This screenshot shows this:
Screenshot
I do not want the blue bar. What I am trying to do is hide or unhide the Black toolbar with the icons on it. (the UITabBar).
I think what I need to do is somehow I need to access the navigation controller of one of the parent view controllers and call the setToolbarHidden on the navigation controller of that view. However, I can't seem to figure out how to do this.
I've tried the following and all seem to have no effect:
[[[self parentViewController] navigationController] setToolbarHidden:YES animated:YES];
or
[[[[[[UIApplication sharedApplication] delegate] window] rootViewController] navigationController] setToolbarHidden:YES animated:YES];
My view controller storyboard consists of the following:
The InitialViewController is a TabBarViewController. It contains three children. One of those children is a UINavigationController. This navigation controller gets several UITableViewController pushed onto it, and eventually a UIViewController is pushed. This last UIViewController is what is seen in the screenshot.
Rough Layout:
TabBarViewController
UIViewController
UITableViewController
UINavigationController
UITableViewController
UITableViewController
UITableViewController
UIViewController
I've tried using
[self parentViewController] parentViewController] parentViewController] ...
to attempt to get back to the top, but this hasn't seemed to work either.
Any suggestions?
I think the problem here might be related to UITabBarController not having a UIToolbar. The setToolbarHidden: method will only apply to the UINavigationController's built-in toolbar (see Apple's documentation). If it's the UITabBarController's tab bar that you actually want to hide, take a look at this post which links to a method using UIView animations directly on the UITabBar.

Resources