gpt4 book ai didi

ios - iPhone 6 的不同 Storyboard

转载 作者:行者123 更新时间:2023-11-28 21:47:10 25 4
gpt4 key购买 nike

我正在配置我的应用程序以针对不同的 iPhone 使用不同的 Storyboard。

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;

if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone)
{
if (iOSDeviceScreenSize.height == 480)
{
// Instantiate a new storyboard object using the storyboard file named Storyboard_iPhone35
UIStoryboard *iPhone35Storyboard = [UIStoryboard storyboardWithName:@"Storyboard_4S" 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];
}
//Not working for iPhone 6 resolution.
if(iOSDeviceScreenSize.height == 667 )
{
UIStoryboard *iphone6Storyboard=[UIStoryboard storyboardWithName:@"Storyboard_Iphone6" bundle:nil];
UIViewController *initialViewController= [iphone6Storyboard instantiateInitialViewController];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = initialViewController;
[self.window makeKeyAndVisible];
}
}
return YES;
}

此代码在 iPhone4 模拟器上运行良好,但在 iPhone 6 模拟器上无法运行。一切似乎都很好,但我无法找出问题所在。它没有检测到 iPhone 6 的屏幕分辨率。请任何人帮助我。

最佳答案

您的应用可能在放大模式下运行,因为您尚未添加对较大手机的支持。如果是这种情况,iPhone 6 的屏幕高度将报告为 568 点,而不是 667。

这是一个解释如何正确添加对较大手机的支持的 SO 答案:https://stackoverflow.com/a/25755436/1025574

关于ios - iPhone 6 的不同 Storyboard,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29676674/

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