-1

我想为三个不同的设备(iphone4s、iphone5 和 ipad)调用 UIStoryboard。我新添加了 iphone4s 设备。我有以下情节提要

  1. 主要_iPhone
  2. Main_iPhone4(新增)
  3. Main_iPad

请检查我当前的来源。它与iphone5一起工作。

AVCamViewController *vc = [[UIStoryboard
storyboardWithName:@"Main_iPhone" bundle:NULL]
                                        instantiateViewControllerWithIdentifier:@"rootController"];

         vc.modalPresentationStyle = UIModalPresentationFormSheet;
         vc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
         [self.viewControllerCam presentViewController:vc animated:YES completion:nil];

我需要像下面这样进行更改,并且我使用 iphone4s 设备运行。但我仍然看到“Main_iPhone”故事板。当我在 iphone4s 设备中运行时,请帮助我如何切换 Main_iPhone4。

UIStoryboard *storyboard = nil;

if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone)
{
   CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;

   if (iOSDeviceScreenSize.height == 480)
   {   
     storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone4" bundle:nil];
   }

   if (iOSDeviceScreenSize.height == 568)
   { 
     storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
   }

} 
else if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad)
{
  storyboard = [UIStoryboard storyboardWithName:@"Main_iPad" bundle:nil];
}

AVCamViewController *vc = [storyboard instantiateInitialViewController];      
vc.view.backgroundColor = [UIColor clearColor];
vc.modalPresentationStyle = UIModalPresentationFormSheet;
vc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self.viewControllerCam presentViewController:vc animated:YES completion:nil];
4

1 回答 1

1

您的代码似乎很好,它应该按照它工作。

但这不是为 iPhone 4s 和 iPhone 5/5s 管理单独故事板的正确方法。相反,您可以使用单个故事板进行管理,并使用自动布局来安排布局,我相信这会减少您的大量工作。

于 2014-07-31T10:25:32.897 回答