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;}
如有疑問請留言或者到本站社區交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
新聞熱點
疑難解答