starting ios project without storyboard

前端 未结 9 1237
渐次进展
渐次进展 2021-01-12 23:28

Im having some troubles to start an iOS app using xibs instead of storyboard. The problem is that im getting a black screen and the first view controller is not being called

9条回答
  •  鱼传尺愫
    2021-01-12 23:50

    To change your project to use xibs instead of storyboards start by creating a xib for each view controller. You will need to change the File's Owner to class to the view controller you are creating the xib for. Then link the File's Owner view outlet to the view in the xib.

    After that, select your app target and change the Main Interface drop down to be empty. Now you can delete the storyboard file.

    Finally, initialize your window in the app delegate's application:didFinishLaunchingWithOptions: method and set your initial view controller as the root view controller of the window. Then call makeKeyAndVisible on your app delegate's window and you should be good to go.

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        // Override point for customization after application launch.
        self.window = [UIWindow new];
        self.window.rootViewController = [ViewController new];
        [self.window makeKeyAndVisible];
        return YES;
    }
    

提交回复
热议问题