我正在制作运行在所有iPhone设备4s,5,5s,6,6+和iPads中的应用程序。
在这里,如果我们选择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中调用此方法。
这段代码在我的另一个应用程序中运行得很好。
发布于 2015-09-08 11:46:49
你的应用程序在你的iPad中放大到iPhone 4的分辨率,你需要将目标设备设置为环球。
发布于 2015-09-08 09:41:45
https://stackoverflow.com/questions/32453954
复制相似问题