swift NavigationViewController。 UIBarButtonItem不会出现
问题描述:
我试图解决几个小时以下的问题,似乎我不明白重要的一点,因为我测试的所有解决方案都不起作用。swift NavigationViewController。 UIBarButtonItem不会出现
起初我目前的分镜: storyboard
我想在“锻炼” -tableView的导航栏添加一个附加按钮,但我不知道怎么回事,因为代码,在“练习作品“-tableview不起作用。
在这里你可以看到 “练习” -tableView的viewDidLoad中()函数:
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.view.backgroundColor = UIColor(red: 110.0/255.0, green: 110.0/255.0, blue: 110.0/255.0, alpha: 1.0)
self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Add, target: self, action: Selector("addItem"))
// addDefaultExercises()
showAtStart()
}
试训,实现代码如下代码几乎是相同的:
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.view.backgroundColor = UIColor(red: 110.0/255.0, green: 110.0/255.0, blue: 110.0/255.0, alpha: 1.0)
self.title = "Your Title"
self.navigationItem.setRightBarButtonItem(UIBarButtonItem(barButtonSystemItem: .Search, target: self, action: "barButtonItemClicked:"), animated: true)
addDefaultPhrases()
}
两个类都从继承的UITableViewController。由于TabViewController的其他FrontPage也不显示按钮,因此TabBarController可能会产生问题。
答
我建议让UITabBarController
作为根&初始视图控制器。
然后创建从UITabBarController
到UINavigationController
,然后从UINavigationController
到workoutsViewController
的关系。然后再重复trainingViewController
。
在导航栏的故事板中添加一个栏按钮项,并更改标识符中的按钮。为两个ViewControllers执行此操作。
现在好了我明白了。有时当你无法自己获得这些简单的解决方案时,这很奇怪。非常感谢你。 – MartinP