I need to set a separate Main Interface for iPhone and iPad, but Xcode only lets me set one interface for the project when it is universal

匆匆过客 提交于 2021-01-28 22:29:24

问题


I am unable to set a specific Main interface for iPad, even though my app is universal. Xcode used to have separate tabs for the Deployment Info on iPhone and iPad but now they are they same. However my game is radically different on iPhone and iPad and I need to set separate storyboards for each interface.

Someone please help if you know the solution.


回答1:


you could set the value in the Deployment Info -> Main Interface to an empty string and implement a custom logic in your AppDelegate:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  // Override point for customization after application launch.

  UIStoryboard *initialStoryboard;
  if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
    initialStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
  } else {
    initialStoryboard = [UIStoryboard storyboardWithName:@"Main_iPad" bundle:nil];
  }

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  self.window.rootViewController = [initialStoryboard instantiateInitialViewController];
  [self.window makeKeyAndVisible];

  return YES;
}



回答2:


You need to use size classes for this. To select the correct size class, open your storyboard file, then click on this icon towards the bottom of the screen.

Clicking wAny hAny will allow you to change the size class type and set specific constraints for the different device types. You can read more information about size classes here



来源:https://stackoverflow.com/questions/33926239/i-need-to-set-a-separate-main-interface-for-iphone-and-ipad-but-xcode-only-lets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!