IOS初始化控制器的实现方法总结

IOS初始化控制器的实现方法总结

一.ViewControllViewController方法

#import "AppDelegate.h"
#import "ViewController.h"

@interface AppDelegate ()

@property(nonatomic,strong) ViewController *viewController;

@end

@implementation AppDelegate


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

  //初始化控制器
  self.viewController = [[ViewController alloc]init];
  //初始化window
  self.window =[[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
  //设置控制器
  self.window.rootViewController = self.viewController;

  return YES;
}

二 .ViewControllViewController 与 xib方法

#import "AppDelegate.h"

#import "XibViewControllViewController.h"

@interface AppDelegate ()

@property(nonatomic,strong) ViewController *viewController;
@property(nonatomic,strong) XibViewControllViewController *xibControllViewController;

@end

@implementation AppDelegate


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

  //初始化控制器
  self.xibControllViewController = [[XibViewControllViewController alloc]initWithNibName:@"XibViewControllViewController" bundle:nil];
  //初始化window
  self.window =[[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
  //设置控制器
  self.window.rootViewController = self.xibControllViewController;


  return YES;
}

如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:notice#nhooo.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。