我创建了NavTitleView.xib(在此xib 2标签中添加了“TITLE”和“SUBTITLE”),并为此xib swift文件创建. 然后我想使用这个xib作为navigationItem.titleView 在viewWillAppear中我写了这段代码 override func viewWi
          然后我想使用这个xib作为navigationItem.titleView
在viewWillAppear中我写了这段代码
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(true)
        let titleView = NSBundle.mainBundle().loadNibNamed("NavTitleView", owner: self, options: nil)[0] as! NavTitleView
        titleView.TitleLabel.text = "My beautiful title"
        titleView.SubtitleLabel.text = "My beautiful subtitle"
        self.navigationItem.titleView = titleView
} 
 一切都很棒!但是当我的视图出现时 – 这个NavTitleView从左侧跳到中心!我不明白为什么?怎么解决?
如果你设置了rightBarButtonItem,请尝试在viewWillAppear中再次调用self.navigationItem.rightBarButtonItem = UIBarButton