【问题标题】:iPhone simulator does not show iphone 5 compatible imageiPhone 模拟器不显示 iphone 5 兼容图像
【发布时间】:2013-01-16 10:31:49
【问题描述】:

我很早就有很多关于新旧 iPhone 屏幕元素设置的问题和答案,并且也得到了一些想法。我有一个疑问...我正在为 iphone 320X480(iPhone)、iphone 视网膜 3.5 英寸和 4 英寸视网膜屏幕准备一个应用程序。对于我想以编程方式设置的窗口(背景)实例。它必须带有标题栏。所以到目前为止我所做的是用

检查了屏幕尺寸
    CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
    if ([UIScreen mainScreen].scale == 2.f && screenHeight == 568.0f) {
       UIImageView *backgroundImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Do-568h@2x.png"]];
    [self.view addSubview:backgroundImage];
    [self.view sendSubviewToBack:backgroundImage];
   } else {

    UIImageView *backgroundImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Do.png"]];
    [self.view addSubview:backgroundImage];
    [self.view sendSubviewToBack:backgroundImage];
   }

第一个块将检查 iphone 5 屏幕(我假设),第二个块将设置屏幕为正常和视网膜两个屏幕,我为其放置 320X480 px 图像名称 Do.png 和 640X960 图像名称 做@2x.png。 iphone 和 iphone 3.5 (Retina) 在模拟器上显示良好,但我认为与 iPhone 5 相同的 iphone 4 (Retina) 无法正确显示。请让我知道我应该怎么做...是的 Do-568h@2x.png640X1136...

【问题讨论】:

  • 是的 Do-568h@2x.png 是 640X1136....
  • 在您的应用程序中也添加此内容,然后它会正确显示 iPhone-4 视网膜图像...
  • 我没明白你...我已经添加了代码和图像...我的意思是我有三个图像不是 Do、Do@2x 和 Do0568h@2x...。

标签: iphone ios5


【解决方案1】:

使用下面的方法设置屏幕大小

- (void)iPhoneDeviceScreenSetting {

    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
        CGSize result = [[UIScreen mainScreen] bounds].size;
        if(result.height == 480)
        {
            // iPhone Classic
            lowerImgVw.frame = CGRectMake(0, 395, 318, 40);
        }
        if(result.height == 568)
        {
            // iPhone 5
            lowerImgVw.frame = CGRectMake(0, 480, 318, 40);
        }
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-16
    • 1970-01-01
    • 2012-01-03
    • 1970-01-01
    • 2013-05-13
    • 1970-01-01
    • 2011-07-09
    相关资源
    最近更新 更多