直接上代码
class ShareViewController: UIViewController {
class var shareDistance:ShareViewController {
struct shareDistance{
static var shareVC:ShareViewController? = nil
static var Once:dispatch_once_t = 0
}
dispatch_once(&shareDistance.Once) { () -> Void in
if shareDistance.shareVC == nil{
//从storyboard上创建vc
let shareVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("ShareViewController")
shareDistance.shareVC = shareVC as? ShareViewController
}
}
return shareDistance.shareVC!
}
}
storyBoard 设置如下图
Paste_Image.png
网友评论