How to add a toolbar to a TableView in iOS
ios, objective-c, toolbar
Solution
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.
Problem
I am building a simple notes application and I want to add a static bar at the bottom of the TableView. For example, I want to add a help button. How can I do this to just my TableView? So far: I have added a toolbar through storyboard, but that makes it stick at the end of the last made tableView cell. I want it stuck to the bottom. I entered this code to do programmatically: ``` @property (strong, nonatomic) IBOutlet UIToolbar *toolbar; ``` in my tableViewController.h file and ``` [self.view addSubview:_toolbar]; [self.navigationController.view setFrame:self.view.frame]; ``` in my tableViewController.m file in my `viewDidLoad` method Thanks!