资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

用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实例化控制器:-创新互联
文章链接:http://cdkjz.cn/article/ddhgpc.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220