Storyboard UITableViewController enable toolbar at bottom of screen
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];
}
How to add a toolbar to a TableView in iOS
The best solution is to use a UIViewController instead of a UITableViewController. (This has been said above, but let me give you the details).
Create a new UIViewController with it's respective XIB. Inside your new UIViewController's view drag in a UITableView, resize it, and drag your UIToolbar wherever you want.
You should have something like this:
The black border represents the UIViewController's main view. The red border represents the table view. The blue border represents your toolbar.
Afterwards, make your UIViewController comply with two protocols: UITableViewDelegate and UITableViewDataSource. You will manually have to implement it's essential methods such us cellForRowAtIndexPath, numberOfRowsInSection, etc, but it shouldn't take you long.
Link your UITableView to your UIViewController. Link it's "data source" and "delegate" properties to the view controller as well.
You will have your setup ready in less than 15 minutes.
Storyboard: How to set a UIToolbar at the bottom of a UITableViewController controlled by a UINavigationViewController
In your ViewController try adding this
[self.navigationController setToolbarHidden:NO animated:YES];
and use this to add BarItems to it
[self setToolbarItems:@[item1, item2, item3] animated:YES];
I'm using this method to add a scan button to a UITableViewController:
UIBarButtonItem *leftSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIBarButtonItem *rightSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
...
...
UIBarButtonItem *scanItem = [[UIBarButtonItem alloc] initWithCustomView:scanButton];
[self setToolbarItems:@[leftSpace, scanItem, rightSpace] animated:YES];
You should be careful because the ToolBar visibility is set for the entire NavigationController you are using and you should show/hide it when needed.
Also the items on it need to be set on each controller (I have this issue, maybe there is a better way to do it)
Hope this helps.
Toolbar in a TableView (Swift)
navigationController?.setToolbarHidden(false, animated: true)
and use storyboard to customise the ToolBar
How to Dock a UIToolbar to the bottom of the screen in UITableView?
You have a couple of options. The first and easiest of the two would be to use a UITableViewController
embedded inside a UINavigationController
, with the navigation controllers toolbarHidden
property set to NO
.
The other option is to use a UIViewController
. A view controller has a UIView
build in, and you can manually add and position a UITableView
and a UIToolbar
on it in this configuration. Both of these configurations will achieve your desired end result.
How to place toolbar above (or below) scrolling tableview
One of the easiest ways to add a toolbar to any view is by embedding it in a NavigationViewController
. All this can be done without code:
Take the View Controller that you currently have (I assume the
UITableViewController
) and under Editor -> Embed In select Navigation Controller.Select the newly created Navigation Controller. In the utilities bar under Bar Visibility, select Toolbar to be shown. If needed you can also keep the Navigation Bar, else turn it off.
Now you are able to modify the Toolbar in
UITableViewController
. Just drag the different Toolbar items (Bar Button Item, Fixed Space Bar Button Item, Flexible Bar Button Item) onto the Toolbar as you please. Be aware, you can't move the toolbar and you can only change its style in theNavigationViewController
.
EDIT:
Since you have a different initial View Controller, I would recommend you solving the issue slightly differently. This will require a little bit of code:
Embed the initial View Controller (the one with the buttons) in an
UINavigationController
. Remove any other Navigation Controllers. Your buttons should simply have a segue that show theUITableViewController
. Disable the Toolbar in the Navigation Controller and as before, it's up to you to enable the Navigation Bar (I would recommend it).If not already created, make a
UITableViewController
class and link it to your Table View Controller.Add this code to the class in order to make the Toolbar appear and disappear when you are viewing the Table View:
import UIKit
class ViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
navigationController?.isToolbarHidden = false
}
override func viewWillDisappear(_ animated: Bool) {
navigationController?.isToolbarHidden = true
}
}
This should be all you'll have to do. If you want to edit the toolbar make it visible while you are editing it and afterwards hide it again.
How to add a toolbar to the BOTTOM of a UITableView obj-c/ios/xcode
First create a view to hold the whole thing.
Then add a UITableview and UIToolbar programmatically set frame so that it appears under the tableview .Add the textfield to the toolbar
UIView *placeholderView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 400, 440)];
UITableView *tv=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, 400, 400)];
[placeholderView addSubview:tv];
UIToolbar *toolBar=[[UIToolbar alloc]initWithFrame:CGRectMake(0, 400, 400, 40)];
[placeholderView addSubview:toolBar];
Related Topics
Add Segmented Control to Navigation Bar and Keep Title with Buttons
How to Create an Ibinspectable of Type Enum
Align Button Image to Right Edge of Uibutton
iOS 6 Rotations: Supportedinterfaceorientations Doesn't Work
Auto Layout Constraint on Calayer iOS
Request Permissions Again After User Denies Location Services
How to Wake Up iOS App with Bluetooth Signal (Ble)
Using Collectionview in Uiview with Xib File
Install iOS App Directly from Website - No Password, No Itunes, No Udid
Behavior Differences Between Performblock: and Performblockandwait:
Show Search Bar in Navigation Bar Without Scrolling on iOS 11
Uiview Atop the Keyboard Similar to Imessage App
Can't Prevent 'Touchmove' from Scrolling Window on iOS
How to Set a Default Value of a Uipickerview
Nsurlsession "Http Load Failed Kcfstreamerrordomainssl, -9813 ; Self Signing Certificate
How to Move Cursor from One Text Field to Another Automatically in Swift iOS Programmatically