iOS   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iOS iPhone 5选择正确的故事板大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试将两个故事板用于我的iOS项目,但我无法让代码切换到相应的故事板.相反,代码绝对没有.是否我没有正确设置控制开关的设置?不属于iPhone 5的设备的主要故事板称为MainStoryboard. iphone 5适当的布局称为iphone5.我想这可能是项目配置设置问题. (这是在我的appdelegate.m文件中).

@H_404_11@-(void)initializeStoryBoardBasedOnScreenSize { if ([UIDevice currentDevice].userInterfaceI@L_611_5@m == UIUserInterfaceIdio@R_247_6165@) { // 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].userInterfaceI@L_611_5@m == UIUserInterfaceI@L_611_5@mPad) { // The iOS device = iPad UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController; UINavigationController *navigationController = [splitViewController.viewControllers lastObject]; splitViewController.delegate = (id)navigationController.topViewController; } }

解决方法

我建议只使1个故事板来处理iPhone 5和iPhone 3-4S屏幕尺寸.

当您的故事板打开时,底部一个按钮可以在两种尺寸之间切换 – 您可以实时查看事物的外观.

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

处理对象的框架和方式位置将受到屏幕大小更改的影响 – 您需要为视图中的每个对象设置自动调整大小属性.您可以通过选择一个对象来执行此操作,并在右侧的“检查器”面板中,选择“大小”检查器,如下所示:

您是否在自动调整框中看到了这些红线?和他们一起玩,看他们将如何影响你的对象.内部的大小(如果宽度或高度伸展),外部的大小与位置有关.

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

你越乱越乱,你会看到每个人做的越多.

大佬总结

以上是大佬教程为你收集整理的iOS iPhone 5选择正确的故事板全部内容,希望文章能够帮你解决iOS iPhone 5选择正确的故事板所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。