0

我正在使用此代码根据设备(iphone 5 或更少)调整我的故事板:

if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
    if(UIScreenOverscanCompensationScale==1136/640){
        //move to your iphone5 storyboard
        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iphone5 storyboard" bundle:[NSBundle mainBundle]];
    }
    else{
        //move to your iphone4s storyboard
        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]];
    }}

即使我只是放置,代码也不起作用:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iphone5 storyboard" bundle:[NSBundle mainBundle]];

...它仍然正常加载 iphone。

我把它放在:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

在应用程序委托中。这是正确的吗??在应用程序设置中,我选择了原始的 iphone 故事板

4

3 回答 3

0

是否MainStoryboard仍在目标摘要下指定?我相信这将是应用程序首先出现的地方。

于 2012-09-23T11:55:50.160 回答
0

我设法以这种方式解决了它:

if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
    if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone && [UIScreen mainScreen].bounds.size.height == 568.0){
        //move to your iphone5 storyboard
        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iphone5 storyboard" bundle:[NSBundle mainBundle]];
        UIViewController *vc =[storyboard instantiateInitialViewController];

        // Set root view controller and make windows visible
        self.window.rootViewController = vc;
        [self.window makeKeyAndVisible];
    }
    else{
        //move to your iphone4s storyboard
        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]];
        UIViewController *vc =[storyboard instantiateInitialViewController];

        // Set root view controller and make windows visible
        self.window.rootViewController = vc;
        [self.window makeKeyAndVisible];
    }}
于 2012-09-23T16:35:32.220 回答
0

问题是:

UIScreenOverscanCompensationScale==1136/640

永远不会是真的。

检查UIScreenOverscanCompensationScale正在做什么并返回一个 BOOL。

于 2012-09-21T16:11:53.540 回答