iOS iPhone 5选择正确的故事板

iOS iPhone 5选择正确的故事板,iphone,ios,objective-c,cocoa-touch,storyboard,Iphone,Ios,Objective C,Cocoa Touch,Storyboard,我试图在iOS项目中同时使用这两个故事板,但我无法让代码切换到相应的故事板。相反,代码什么也不做。是不是我没有正确设置控制开关的设置?非iPhone5设备的主情节提要称为主情节提要。iphone5的适当布局称为iphone5。我认为这可能是一个项目配置设置问题。这在我的appdelegate.m文件中 -(void)initializeStoryBoardBasedOnScreenSize { if ([UIDevice currentDevice].userInterfaceIdio

我试图在iOS项目中同时使用这两个故事板,但我无法让代码切换到相应的故事板。相反,代码什么也不做。是不是我没有正确设置控制开关的设置?非iPhone5设备的主情节提要称为主情节提要。iphone5的适当布局称为iphone5。我认为这可能是一个项目配置设置问题。这在我的appdelegate.m文件中

-(void)initializeStoryBoardBasedOnScreenSize {

    if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone)
    {    // The iOS device = iPhone or iPod Touch


        CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;

        if (iOSDeviceScreenSize.height == 480)
        {   // iPhone 3GS, 4, and 4S and iPod Touch 3rd and 4th generation: 3.5 inch screen (diagonally measured)

            // Instantiate a new storyboard object using the storyboard file named Storyboard_iPhone35
            UIStoryboard *iPhone35Storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];

            // Instantiate the initial view controller object from the storyboard
            UIViewController *initialViewController = [iPhone35Storyboard instantiateInitialViewController];

            // Instantiate a UIWindow object and initialize it with the screen size of the iOS device
            self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

            // Set the initial view controller to be the root view controller of the window object
            self.window.rootViewController  = initialViewController;

            // Set the window object to be the key window and show it
            [self.window makeKeyAndVisible];
        }

        if (iOSDeviceScreenSize.height == 568)
        {   // iPhone 5 and iPod Touch 5th generation: 4 inch screen (diagonally measured)

            // Instantiate a new storyboard object using the storyboard file named Storyboard_iPhone4
            UIStoryboard *iPhone4Storyboard = [UIStoryboard storyboardWithName:@"iphone5" bundle:nil];

            // Instantiate the initial view controller object from the storyboard
            UIViewController *initialViewController = [iPhone4Storyboard instantiateInitialViewController];

            // Instantiate a UIWindow object and initialize it with the screen size of the iOS device
            self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

            // Set the initial view controller to be the root view controller of the window object
            self.window.rootViewController  = initialViewController;

            // Set the window object to be the key window and show it
            [self.window makeKeyAndVisible];
        }

    } else if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad)

    {   // The iOS device = iPad

        UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
        UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
        splitViewController.delegate = (id)navigationController.topViewController;

    }
}

我建议只使用1个故事板来处理iPhone5和iPhone3-4S的屏幕尺寸

当你的故事板打开时,底部有一个按钮可以在两种尺寸之间切换——你可以实时看到事情的样子

该按钮位于右下角“放大%”和“缩小”按钮的左侧,如下所示:

要处理屏幕大小更改对对象帧和位置的影响,需要为视图中的每个对象设置自动调整大小属性。可以通过选择一个对象来执行此操作,然后在右侧的“检查器”面板中选择“尺寸检查器”,如下所示:

看到自动调整大小框中的红线了吗?和他们一起玩,看看他们会如何影响你的目标。如果宽度或高度延伸,则内部与尺寸相关,外部与位置相关

我不确定你的应用程序的布局,但根据经验,你可能必须搞乱内部的垂直线——高度将如何变化,以及你希望它保持在底部附近的底线


你越是胡闹,你就越能看到每个人的所作所为。

我可以看到iPhone和iPad使用了两种不同的故事板,但是,在您查看故事板时,有一个不错的按钮可供使用,它允许您在iPhone 5屏幕大小和以前的屏幕大小之间切换,因此您不必创建两个全新的故事板。你需要单独的故事板有什么特别的原因吗?没有,你的解决方案就是我想要的。这个按钮在哪里?这很有帮助,但是如何为特定视图调整对象的大小,而该视图不会随其他视图配置而改变?如果您没有看到上面显示的带有红线的自动调整大小框,请告诉我,您必须关闭自动布局。我关闭了自动布局,但我的导航栏会显示在屏幕底部。关于如何解决这个问题有什么想法吗?你是将它拖进去了还是通过进入编辑器->嵌入->导航控制器将UIViewController嵌入到UINavigationController中了?如果它是嵌入的,它永远不应从顶部移动-如果您拖动它,请单击它,并确保选择的唯一自动调整大小栏是顶部的和宽度的。