我使用的XCode我添加了一个工具栏,以我的导航控制器。 我想栏按钮添加到工具栏。 在我的故事板,我试图控制拖“栏按钮项目”到工具栏,但不工作,没有被添加。
所以“栏按钮项目”到工具栏?
谢谢。
更新:
添加我自己的UINavigationController,从故事板工具栏绑定到我的班为“mytoolbar”。 并没有在迅速的答案代码,但是当我在模拟器上运行它,我没有看到任何工具栏项目。
class AppNavigationController: UINavigationController {
@IBOutlet weak var mytoolbar: UIToolbar!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
var rightButton = UIBarButtonItem(title: "Title", style: UIBarButtonItemStyle.Plain, target: self, action: Selector("method"))
var items = [AnyObject]()
items.append(rightButton)
mytoolbar.items = items
}
func method() {
println("Something cool here")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}