我正在尝试回到我的应用程序中的上一个视图,并且我正在使用popViewControllerAnimated方法,但是当按下后退按钮时,这不会执行任何操作。我在这里错过了什么吗?
import UIKit
class SubjectsViewController: UIViewController {
@IBOutlet var myTableView: UITableView!
@IBOutlet var noBooksLabel: UILabel!
@IBOutlet var navigationBarTitle: UINavigationBar!
func backAction() -> Void {
if let navController = self.navigationController {
navController.popViewControllerAnimated(true)
}
//self.navigationController?.popViewControllerAnimated(true)
}
override func viewWillAppear(animated: Bool) {
self.noBooksLabel.hidden = true
}
override func viewDidLoad() {
super.viewDidLoad()
descriptions.removeAll(keepCapacity: true)
usernames.removeAll(keepCapacity: true)
imageFiles.removeAll(keepCapacity: true)
println("Subject view controller")
self.navigationBarTitle.topItem?.title = "\(selectedSubject)"
let backButton = UIBarButtonItem(title: "Back", style: UIBarButtonItemStyle.Plain, target: self, action: "backAction")
self.navigationBarTitle.topItem?.leftBarButtonItem = backButton