简体   繁体   中英

Adding a Toolbar to a UITableViewController Using Swift

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM