我以编程方式在我的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) 有没有办法以编程方式使用蓝牙将文件从一个iOS设备发送到另一个设备.我使用过Air Drop,但似乎无法在iOS中找到适合蓝牙文件传输的代码片段.