欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

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

程序员文章站 2023-12-18 10:30:40
ios初始化控制器的实现方法总结 一.viewcontrollviewcontroller方法 #import "appdelegate.h" #import...

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;
}

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

上一篇:

下一篇: