初学swift,代码加载xib storyboard
-.加载xib
override init(nibName nibNameOrNil: String?,bundle nibBundleOrNil: NSBundle?){ super.init(nibName: nibNameOrNil,bundle: nibBundleOrNil) } convenience init() { var nibNameOrNil = String?("ViewController") self.init(nibName: nibNameOrNil,bundle: nil) } required init(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") }
二.加载storyboard 跳转到storyboard
var jumpViewController: ViewController = UIStoryboard(name: "Main",bundle: nil).instantiateViewControllerWithIdentifier("Storyboard ID") as! ViewController self.navigationController?.pushViewController(jumpViewController,animated: true)
Storyboard ID 是storyboard绑定的ID viewController 是绑定的Class