AppDelegate单例模式、通过StoryBoardId加载ViewController Swift

前端之家收集整理的这篇文章主要介绍了AppDelegate单例模式、通过StoryBoardId加载ViewController Swift前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

varappDelegate =UIApplication.sharedApplication().delegateas!AppDelegate

Swift中 有时候添加ViewController的时候,我们需要使用UIStoryboard进行加载

我们在AppDelegate中创建MainStoryBoard

varstoryBoard:UIStoryboard?

storyBoard=UIStoryboard(name:"Main",bundle:nil)

funcgetMainStoryBoard()->UIStoryboard{

returnstoryBoard!

}

varcir_vc:CircleImageViewController! =appDelegate.getMainStoryBoard().instantiateViewControllerWithIdentifier("CircleImageViewController")as!CircleImageViewController

self.navigationController?.pushViewController(cir_vc,animated:true)

通过StoryBoardId创建了ViewController

猜你在找的Swift相关文章