gpt4 book ai didi

ios - 制作专为 4 英寸显示器设计的 iPhone 应用程序,兼容 3.5 英寸显示器

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:47:37 24 4
gpt4 key购买 nike

我的应用在设计时只考虑了 4 英寸显示屏。在 3.5 英寸模拟器上运行时,应用程序会丢失 0.5 英寸。

那么,我的问题是,如何在 Xcode 5 中为不同的屏幕尺寸设置不同的 Storyboard?

我知道在我可以使用以下代码之前:

-(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 *Main_iPhone2 = [UIStoryboard storyboardWithName:@"Main_iPhone3" bundle:nil];

// Instantiate the initial view controller object from the storyboard
UIViewController *initialViewController = [Main_iPhone2 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 *Main_iPhone = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];

// Instantiate the initial view controller object from the storyboard
UIViewController *initialViewController = [Main_iPhone 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;

}

但是与 Xcode 5 的交易,我认为这段代码不起作用的原因是,在您的项目中的“常规”下有一个部分将 Storyboard建立为整个特定设备类型的主要部分。

所以,要么有不同的方法来完成整个独立的 Storyboard ,要么我的代码有问题。该代码已放在我的应用程序委托(delegate)中,所以请不要认为我那里有任何问题。

最佳答案

Storyboard in Xcode 5 with autolayout enabled

在 Xcode 5 - Storyboard 中找到这个控件。一直向左的按钮在整个 Storyboard 中的 3.5 和 4 英寸 View 之间切换。希望这就是您所需要的。

关于ios - 制作专为 4 英寸显示器设计的 iPhone 应用程序,兼容 3.5 英寸显示器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18889505/

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