Search code examples
xcodeuitableviewtoolbar

Xcode: How to fix the toolbar for a tableView?


I have a tableView and want to add a toolbar at the bottom with a sync button and the latest sync date (like on the Mail-app on the iPhone). But the Scrollbar should be fixed, so that it doesn't move when I scroll trough the table view.

Right now, I'm just adding the searchBar programmatically by:

self.tableView.tableFooterView = self.toolbar;

Another problem linked here is the fact, that I'm using the MasterDetailsView Controller template of Xcode. But I can't just drag a toolbar into my MasterView (containing the tableview). My first guess is that its just fixed because of the template I used but I'm not quite sure about it.

Thanks in advance!!


Solution

  • Instead of using a UITableViewController try using a plain UIViewController which conforms to UITableViewDelegate and UITableViewDataSource. Add a UITableView as a subview to the view controller's main view and link its delegate and datasource to the view controller.

    Now, you can add any other UIViews to the main view which will appear fixed on top of the UITableView.