gpt4 book ai didi

iphone - iOS iPhone 5 选择正确的 Storyboard

转载 作者:可可西里 更新时间:2023-11-01 05:23:11 25 4
gpt4 key购买 nike

我正在尝试为我的 iOS 项目使用这两个 Storyboard,但我无法获得切换到适当 Storyboard的代码。相反,代码什么都不做。是我没有正确设置控制开关的设置吗?非 iPhone 5 设备的主 Storyboard称为 MainStoryboard。 iphone 5 合适的布局称为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 个 Storyboard来处理 iPhone 5 与 iPhone 3-4S 的屏幕尺寸。

当您的 Storyboard 打开时,底部有一个按钮可以在 2 种尺寸之间切换——您可以实时查看事物的外观。

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

enter image description here

要处理对象的框架和位置将如何受屏幕尺寸变化的影响——您需要为 View 中的每个对象设置自动调整大小属性。您可以通过选择一个对象来完成此操作,然后在右侧的检查器面板中,选择大小检查器,如下所示:

enter image description here

您看到“自动调整大小”框中的那些红线了吗?与它们一起玩,看看它们将如何影响您的对象。内部的与大小相关(如果宽度或高度拉伸(stretch)),外部的与位置相关。

我不确定您的应用程序布局,但根据经验,您可能不得不弄乱内部垂直线(高度将如何变化)和底线(您希望它保持在底部附近)。

你对每一个的了解越多,你就会越了解每一个的作用。

关于iphone - iOS iPhone 5 选择正确的 Storyboard,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14266776/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com