用Storyboard实例化控制器:

步骤一:手动初始化storyboard.

公司主营业务:网站设计制作、网站建设、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联公司是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联公司推出岱岳免费做网站回馈大家。

  1. 首先删除系统自动创建的ViewController.h, ViewController.m 和 main.storyboard这三个文件。

   2.  点击项目——>General——>Deployment Info,在Main Interface选项中将main删除。

   3.   新建一个Storyboard文件,拖一个控制器,在拖一个按钮。点击storyboard上方的导航条,在右侧“属性”栏下view Controller复选框中Title下方将“Is  Initial View Controller”勾选上。

   4.    在AppDelegate.m文件中的didFinishLaunchingWithOptions方法中填写下面代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

   

//    1. Create a window

   self.window = [[UIWindowalloc]initWithFrame:[UIScreenmainScreen].bounds];

    

//    2. Create Controller(A StoryBoard)

   UIStoryboard *story = [UIStoryboardstoryboardWithName:@"Storyboard"bundle:nil];

    

//    2.1 Instantiate Controller (With Sweet(jian tou))

   UIViewController *vc = [storyinstantiateInitialViewController];

    

//    3. Set the window Root Controller

   self.window.rootViewController = vc;

    

//    4. Put the window as the Main Window and visible

    [self.windowmakeKeyAndVisible];

    

   returnYES;

}

步骤二:通过标记初始化storyboard。

  1. 首先删除系统自动创建的ViewController.h, ViewController.m 和 main.storyboard这三个文件。

   2.  点击项目——>General——>Deployment Info,在Main Interface选项中将main删除。

   3.   新建一个Storyboard文件,拖一个控制器,在拖一个按钮。点击storyboard上方的导航条,在右侧“属性”栏左侧选项中identity选项下storyboard ID里填写“Vstar”,之后点击回车键。

   4.    在AppDelegate.m文件中的didFinishLaunchingWithOptions方法中填写下面代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

   

//    1. Create a window

   self.window = [[UIWindowalloc]initWithFrame:[UIScreenmainScreen].bounds];

    

//    2. Create Controller(A StoryBoard)

   UIStoryboard *story = [UIStoryboardstoryboardWithName:@"Storyboard"bundle:nil];

    

//    2.1 Instantiate Controller (With Sweet(jian tou))

   UIViewController *vc = [storyinstantiateViewControllerWithIdentifier:@"Vstar"];

    

//    3. Set the window Root Controller

   self.window.rootViewController = vc;

    

//    4. Put the window as the Main Window and visible

    [self.windowmakeKeyAndVisible];

    

   returnYES;

}

当前文章:用Storyboard实例化控制器:
路径分享:https://www.cdcxhl.com/article30/ijjcso.html

成都网站建设公司_创新互联,为您提供营销型网站建设定制网站建站公司网站策划网站制作品牌网站设计

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

微信小程序开发