简体   繁体   English

Objective-C ios 应用程序布局

[英]objective-c ios app layout

How to fit size for iphone 5s , iphone 6s and iphone 6plus .如何适合iphone 5siphone 6siphone 6plus尺寸。

Do I need to make separate story board if so could you any body tell me how to make separate story board for a specific view controller .如果需要的话,我是否需要制作单独的故事板,您是否可以告诉我如何为特定的视图控制器制作单独的故事板。

Please do not use a separate storyboard for each screen size.请不要为每个屏幕尺寸使用单独的故事板。 The system contains functionality specifically so you do not have to do that.该系统包含专门的功能,因此您不必这样做。

Apple provides lots of really great documentation on this topic online. Apple 在线提供了许多关于此主题的非常棒的文档。 I would recommend that you start with this site:我建议你从这个网站开始:

https://developer.apple.com/design/adaptivity/ https://developer.apple.com/design/adaptivity/

In particular you want to look up information about Auto Layout and NSLayoutConstraint .特别是您想查找有关 Auto Layout 和NSLayoutConstraint There are several WWDC videos (linked from the page above) that discuss the topic.有几个 WWDC 视频(从上面的页面链接)讨论了该主题。

If you are using AutoLayout then there is no need for separate storyboards for each device.如果您使用 AutoLayout,则不需要为每个设备单独的故事板。 AutoLayout managed all things for you if you provide proper constraints and size classes.如果您提供适当的约束和大小类,AutoLayout 会为您管理所有事情。

If you really need a separate storyboards for each device so here is the solution:如果您真的需要为每个设备单独的故事板,那么这里是解决方案:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

UIViewController *initialViewController = nil;
UIStoryboard *storyboard;
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone)
{
    CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
    if (iOSDeviceScreenSize.height ==  667)
    {
        storyboard = [UIStoryboard storyboardWithName:@"6board" bundle:nil];
        initialViewController = [storyboard instantiateInitialViewController];
    }else if (iOSDeviceScreenSize.height == 736){
        storyboard = [UIStoryboard storyboardWithName:@"6plus" bundle:nil];
        initialViewController = [storyboard instantiateInitialViewController];
    }else{
        storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        initialViewController = [storyboard instantiateInitialViewController];
    }
}else{
    storyboard = [UIStoryboard storyboardWithName:@"ipadboard" bundle:nil];
    initialViewController = [storyboard instantiateInitialViewController];
}
 self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [self.window makeKeyAndVisible];
    self.window.rootViewController  = initialViewController;

不同设备的故事板

Hope it's helped you... Happy Codding希望它对你有帮助......快乐编码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM