Ash*_*han 8 uinavigationbar swift ios8
我以编程方式在我的Superview中添加了UINavigationBar,名为BaseViewController,它继承了UIViewController.但是当我尝试为UINavigationBar设置标题时.我收到称为致命错误的错误:无法解包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)
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17678 次 |
| 最近记录: |