推送UIViewController

时间:2016-09-12 06:39:46

标签: ios swift uinavigationcontroller

如果我将推送视图控制器的导航栏上的标题和按钮设置为带有navigationController.pushViewController(controller:animated:completion:)的navigationController,同时保持“返回”按钮,该怎么设置?

提前谢谢!

2 个答案:

答案 0 :(得分:0)

如果有人想知道如何执行此操作,请直接覆盖推送的UIViewController navigationItem属性。我的错误是我试图用self.navigationController?.navigationItem

来完成这个任务

答案 1 :(得分:0)

以下是您应编写的代码,以便设置导航标题和左键

代码:

    override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.

    //For Setting Title
    self.title = "New Title";

    //For setting button in place of back button
    let leftItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Cancel, target: self, action: "leftButtonClicked");
    self.navigationItem.leftBarButtonItem = leftItem;
}

快乐的编码......