【问题标题】:iOS 6 background imageiOS 6 背景图片
【发布时间】:2012-09-27 23:43:22
【问题描述】:

我有一个带有全屏渐变背景的 iOs 应用程序。现在,iphone 5 的屏幕尺寸不同,当然我想同时支持第 5 和第 4 设备。

推荐的方法是什么?

【问题讨论】:

    标签: iphone screen-size


    【解决方案1】:

    来自我在评论中链接到的帖子

    #import <sys/utsname.h>
    
    NSString*
    machineName()
    {
    struct utsname systemInfo;
    uname(&systemInfo);
    
    return [NSString stringWithCString:systemInfo.machine
                              encoding:NSUTF8StringEncoding];
    }
    

    结果应该是:

    @"i386"      on the simulator
    @"iPod1,1"   on iPod Touch
    @"iPod2,1"   on iPod Touch Second Generation
    @"iPod3,1"   on iPod Touch Third Generation
    @"iPod4,1"   on iPod Touch Fourth Generation
    @"iPhone1,1" on iPhone
    @"iPhone1,2" on iPhone 3G
    @"iPhone2,1" on iPhone 3GS
    @"iPad1,1"   on iPad
    @"iPad2,1"   on iPad 2
    @"iPhone3,1" on iPhone 4
    @"iPhone4,1" on iPhone 4S
    

    我假设这将为最新型号返回类似 @"iPhone5,1" 的内容。然后像这样检查一下

    NSString *iphoneType = machineName();
    if ([iphoneType isEqualToString@"iPhone5,1"]){
        //image for iphone 5
    } else {
               //image for the rest
    }
    

    让我知道这是否有效

    【讨论】:

    • 程序方式清晰。可能有“Apple批准”的东西吗?比如拥有带有@xxx 名称的图片等
    • 你是说整个背景都是一张图片?
    • 看看这个线程。 stackoverflow.com/questions/1108859/… Will Harris 有一个答案,这将是您想要的。我将编辑我的答案,但功劳归于他。