在导航栏栏按钮中更改按钮标识符

时间:2015-04-21 19:23:20

标签: ios swift

我之前已经问过这个问题,并且我发现了两行不同的代码,这些代码旨在对导航栏中的条形按钮项的标识符进行更改。两者都编译,但对标识符都没有任何影响。我启动程序时将标识符设置为“播放”按钮,并希望将其更改为“暂停”按钮。我在viewDidLoad()和inside

中都运行了这两行代码
IBAction func startButton(sender: AnyObject) {

这是代码。谁能告诉我为什么按钮标识符没有改变?并且,右边的Button / leftButton是否显得如此明显,或者代码中的某些内容与我无法获得。

self.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .Pause, target: self, action: "startButton:")

self.navigationItem.setLeftBarButtonItem(UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Pause, target: self, action: "startButton"), animated: true)

这是整个viewDidLoad,它也不起作用。

override func viewDidLoad() {
    super.viewDidLoad()
    self.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .Pause, target: self, action: "startButton:")
}

0 个答案:

没有答案
相关问题