为什么我的故事板在iphone上工作?

时间:2015-06-10 22:14:44

标签: ios objective-c iphone storyboard

在app delegate中我写了这个以确定将根据屏幕大小打开哪个故事板,

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIStoryboard *storyboard = [self grabStoryboard];

// show the storyboard
self.window.rootViewController = [storyboard instantiateInitialViewController];
[self.window makeKeyAndVisible];

return YES;
}

- (UIStoryboard *)grabStoryboard {

UIStoryboard *storyboard;

// detect the height of our screen
int width = [UIScreen mainScreen].bounds.size.width;

if (width == 480) {
    storyboard = [UIStoryboard storyboardWithName:@"iphone4" bundle:nil];
    // NSLog(@"Device has a 3.5inch Display.");
} else {
    storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    // NSLog(@"Device has a 4inch Display.");
}

return storyboard;
}

该应用会在设备上打开横向视图。 这将在模拟器中正确选择3.5英寸设备和4英寸设备,但不能在实际的3.5英寸设备中正确显示。在Xcode 6中,它打开4s或5,6,6 +的正确故事板,具体取决于屏幕的宽度,但在实际的Iphone 4s(使用ios 7.1.1)上测试时,将显示为4英寸设备配置的故事板

0 个答案:

没有答案