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

时间:2021-05-20

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

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

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章