[英]Bar Buttons Not Showing Up - Swift
I ran my app and I'm having a hard time removing the back button (My UITableViewController
has a Navigation Controller with a relationship to a TabBar
Controller) and adding the bar button to my app. 我运行了我的应用程序,但我很难删除后退按钮(我的
UITableViewController
具有与TabBar
控制器有关系的导航控制器)并将bar按钮添加到我的应用程序。 Here's what it looks like in the storyboard: 这是情节提要中的外观:
Code: 码:
class FeedTableViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
// MARK: - Table view data source
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Potentially incomplete method implementation.
// Return the number of sections.
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete method implementation.
// Return the number of rows in the section.
return 0
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewWillAppear(animated: Bool) {
self.navigationItem.hidesBackButton = true
}
@IBAction func publishPhoto(sender: AnyObject) {
self.performSegueWithIdentifier("publishPhotoOrVideo", sender: self)
}
}
You can programmatically create the rightBar Button using following code. 您可以使用以下代码以编程方式创建rightBar Button。 you need to add following code in
viewDidLoad
method. 您需要在
viewDidLoad
方法中添加以下代码。
var refreshButton = UIBarButtonItem(barButtonSystemItem: .Refresh, target: self, action: "buttonMethod") //Use a selector
self.navigationItem.rightBarButtonItem = refreshButton
Or if you have reference then you can directly assign as followed. 或者,如果您有参考,则可以直接按照以下说明进行分配。
self.navigationItem.rightBarButtonItem = publicPhotoButton
Hope this help you. 希望这对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.