Я программно добавил UINavigationBar в свой Superview с именем BaseViewController, который наследует UIViewController. Но когда я пытаюсь установить заголовок для UINavigationBar. Я получаю сообщение об ошибке fatal error: Can't unwrap Optional.None
Ниже мой быстрый класс. Как развернуть и изменить заголовок UINavigationBar
import UIKit
class BaseViewConroller: UIViewController {
var navBar:UINavigationBar=UINavigationBar()
override func viewDidLoad() {
super.viewDidLoad()
setNavBarToTheView()
// Do any additional setup after loading the view.
navBar.topItem.title="test test"
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func setNavBarToTheView()
{
navBar.frame=CGRectMake(0, 0, 320, 50)
navBar.backgroundColor=(UIColor .blackColor())
self.view .addSubview(navBar)
}
}