I am unable to add a tool bar to my tableView using the Xcode main.storyboard. Thus, I tried coding it in manually in the viewDidLoad()
let logOutButton = UIBarButtonItem(title: "Log Out", style: UIBarButtonItemStyle.Bordered, target: self, action: "logOut")
var bottomBarButtonArray = [UIBarButtonItem]()
bottomBarButtonArray.append(logOutButton)
self.navigationController!.setToolbarHidden(false, animated: true)
self.navigationController!.toolbar.items = bottomBarButtonArray
May I know how do I set the logOutButton text and also how to detect if logOutButton has been pressed.
I tried logOutButton.description = "Log Out"
but it does not work.
My toolbar does appear but I have no idea how to add the text for the logout button.
The solution is to use UIViewController as parent class and not UITableViewController
If the TableView happens to be embedded in a Navigation Controller, there is an easy solution: you can add the Toolbar straight away in the NavigationController. The checkbox 'Shows Toolbar' in the Attributes Inspector is all you need. Details: https://stackoverflow.com/a/34832688/5897915
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.