用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 = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];

//  2. Create Controller(A StoryBoard)

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

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

  UIViewController *vc = [story instantiateInitialViewController];

//  3. Set the window Root Controller

  self.window.rootViewController = vc;

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

  [self.window makeKeyAndVisible];

  return YES;

}

步骤二:通过标记初始化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 = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];

//  2. Create Controller(A StoryBoard)

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

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

  UIViewController *vc = [story instantiateViewControllerWithIdentifier:@"Vstar"];

//  3. Set the window Root Controller

  self.window.rootViewController = vc;

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

  [self.window makeKeyAndVisible];

  return YES;

}

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。

网站题目:用Storyboard实例化控制器:-创新互联
当前URL:https://www.cdcxhl.com/article32/ddhgpc.html

成都网站建设公司_创新互联,为您提供App开发建站公司关键词优化移动网站建设定制开发外贸网站建设

广告

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

网站托管运营