不使用Main.storyboard

今天学习ios,但是发现创建的工程里面总是使用了Main.storyboard,那么如果想编码实现怎么办?

1.删除Main storyboard file base name

位于Supporting Files中的Info.plist


2.在AppDelegate的- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 方法中实现如下代码

ViewController *rootViewControllor = [[ViewController alloc] initWithNibName:nil bundle:nil];

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor whiteColor];
    self.window.rootViewController = rootViewControllor;
[_window makeKeyAndVisible];


你可能感兴趣的:(iOS)