我正在制作适用于所有iPhone设备4s,5,5s,6,6 +和iPad的应用程序..
如果我们选择iPhone 4s模拟器,它将加载4s故事板。 我为不同尺寸的屏幕设计了独立的故事板。
它适用于所有iPhone设备,但当我在模拟器选项中选择iPad时,它会给我iPhone 4s屏幕。
这是根据AppDelegate中的屏幕大小加载不同故事板的代码。
- (UIStoryboard *)grabStoryboard
{
// determine screen size
int screenHeight = [UIScreen mainScreen].bounds.size.height;
NSLog(@"screenHeight:-%d",screenHeight);///here it it gives me 480 in iPad so it goes in case 480.
UIStoryboard *storyboard;
switch (screenHeight)
{
// iPhone 4s
case 480:
storyboard = [UIStoryboard storyboardWithName:@"Main-4s" bundle:nil];
break;
// iPhone 5s
case 568:
storyboard = [UIStoryboard storyboardWithName:@"Main-5s" bundle:nil];
break;
// iPhone 6
case 667:
storyboard = [UIStoryboard storyboardWithName:@"Main-6" bundle:nil];
break;
// iPhone 6 Plus
case 736:
storyboard = [UIStoryboard storyboardWithName:@"Main-6Plus" bundle:nil];
break;
default:
// it's an iPad
storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
break;
}
return storyboard;
}
在didFinishLaunchingWithOptions中调用此方法。
此代码在我的其他应用中运行良好。
答案 0 :(得分:1)
您的应用在iPad中放大到iPhone 4的分辨率。您需要将目标设备设置为通用。
答案 1 :(得分:0)
无需为每个分辨率配置单独的故事板。在Xcode中,您可以通过Interface Builder配置不同屏幕尺寸的布局。在底部,您可以更改各种屏幕尺寸的约束。
Here's a brief tutorial应该让你指向正确的方向。