【发布时间】:2016-07-10 00:32:00
【问题描述】:
看完这个问题:How to set back button text in Swift,
我开始将用于配置导航栏右键的代码移动到调用我正在呈现的 xib (ParticipantEditorViewController) 的视图控制器,如下所示:
import UIKit
class ViewController: UIViewController {
/*
* This is placeholder class. The code below will need to be added to whichever view controllers summon the participant editor, in their prepareForSegue method.
*/
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
print("snap")
if let participantEditor = segue.destinationViewController as? ParticipantEditorViewController {
print("crackle")
let barButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Action, target: participantEditor, action: nil)
// let barButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Action, target: participantEditor, action: Selector(participantEditor.presentActionMenu()))
print("pop")
navigationItem.rightBarButtonItem = barButton
}
}
}
但我仍然无法以编程方式配置导航栏。关于我所缺少的任何帮助?
【问题讨论】:
-
snap、crackle 和 pop 字符串正在打印到控制台,所以我知道 if-let 触发等...
标签: ios swift uibarbuttonitem