UIStoryboard load from app delegate

前端 未结 4 1416
情歌与酒
情歌与酒 2021-01-11 13:24

I am trying to load a UIStoryboard from the app delegate .m in this way:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDi         


        
4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-11 13:36

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    
       UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]];
       UIViewController *vc =[storyboard instantiateInitialViewController];
    
       // Set root view controller and make windows visible
       self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
       self.window.rootViewController = vc;
       [self.window makeKeyAndVisible];
    
       return YES;
    }
    

    Try this. I think is missing set root view controller and make windows visible.

提交回复
热议问题