【发布时间】:2015-02-07 16:11:00
【问题描述】:
我正在尝试将主页按钮添加到导航控制器。因此我创建了下面的类并将我的导航控制器分类。我的按钮出现在我的第一个视图上。当我导航到其他视图(我的图片中的表格视图)时,添加的按钮消失了。我正在使用 segues 推送到另一个视图。
class ThemedNavigationController: UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()
var home = UIBarButtonItem(image: UIImage(named: "home"), style: UIBarButtonItemStyle.Plain, target: self, action: "doneAction")
navigationBar.topItem?.rightBarButtonItem = home
navigationBar.barTintColor = anaRenk
navigationBar.barStyle = .Black
navigationBar.titleTextAttributes = [NSFontAttributeName: UIFont(name: sansSerifName, size: 17)!]
UIBarButtonItem.appearance().setTitleTextAttributes(
[NSFontAttributeName: UIFont(name: sansSerifName, size: 17)!],
forState: .Normal)
}
func doneAction() { // [6]
self.navigationController?.popToRootViewControllerAnimated(true)
}
}
在我的 mainViewController 没有导航控制器之前。相反,每个按钮都在推动具有单独导航控制器的新视图控制器,并且我的代码正在运行。如果您能告诉我如何解决此问题,我将不胜感激。
【问题讨论】:
标签: ios swift uinavigationcontroller