swift 代码加载xib storyboard

2015-08-07 16:22

初学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


版权声明:本文为博主原创文章,未经博主允许不得转载。