Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a Toolbar to a UITableViewController Using Swift

Tags:

swift

ios8.3

I wish to add a toolbar to the bottom of a tableview. In this stackoverflow post I learned that "If your UITableViewController is embedded in UINavigationController, the navigation controller comes with a toolbar. You wouldn't need to add your own.". The author of that post proceeds to lists the objective-c code to make it visible. Could I please be directed to a tutorial or example which demonstrates the swift code that will to the same thing? I am new to iOS apps and Xcode, learning it as I go.

like image 927
Delete My Account Avatar asked Feb 22 '26 16:02

Delete My Account


1 Answers

To make the toolbar visible, simply use this function in the viewDidLoad :

self.navigationController!.setToolbarHidden(false, animated: true)

To populate with items, you have the setToolbarItem function :

self.navigationController!.setToolbarItems(<toolbarItems: [AnyObject]?>, animated: <Bool>)

Here is the link for the UINavigationController class reference

like image 91
Dean Avatar answered Feb 25 '26 07:02

Dean