当前位置: 首页 > 新闻动态 > 软件编程

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

作者:用户投稿 浏览: 发布日期:2026-01-11
[导读]:这篇文章主要介绍了IOS初始化控制器的实现方法总结的相关资料,这里提供两种实现方法分别是ViewControllViewController方法和 ViewControllViewController 与 xib方法,需要的朋友可以参考下

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

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

免责声明:转载请注明出处:http://sczxchw.cn/news/240087.html

扫一扫高效沟通

多一份参考总有益处

免费领取网站策划SEO优化策划方案

请填写下方表单,我们会尽快与您联系
感谢您的咨询,我们会尽快给您回复!