【问题标题】:Images in UIAlertView: CGRectMake in retina and non-retina iPhoneUIAlertView 中的图像:视网膜和非视网膜 iPhone 中的 CGRectMake
【发布时间】:2012-08-17 17:54:14
【问题描述】:

我正在开发一个应用程序,我在 UIAlertView 中显示一些图标以说明它们的使用。 我是这样做的:

UIAlertView *helpAlert = [[UIAlertView alloc] initWithTitle:@"The button:\n\n  is used to do... \n\n  " message:@"" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];

    UIImageView *imageView1 = [[UIImageView alloc] initWithFrame:CGRectMake(20, 55, 40, 40)]; 
    NSString *path1 = [[NSString alloc] initWithString:[[[NSBundle mainBundle] resourcePath]   stringByAppendingPathComponent:@"bottle_w_40.png"]];
    UIImage *bkgImg1 = [[UIImage alloc] initWithContentsOfFile:path1];
    [imageView1 setImage:bkgImg1];
    [bkgImg1 release];
    [path1 release];

    [helpAlert addSubview:imageView1];
    [imageView1 release];
    [helpAlert show];
    [helpAlert release];

它在模拟器和我的 iphone 3gs(没有视网膜显示)中运行良好。我的伙计是关于视网膜行为的。图片位置会不一样吗?我是否需要为 CGRectMake 使用一些 scaleFactor 或 UIAlertview 中的位置是绝对的?

【问题讨论】:

    标签: iphone uialertview cgrectmake


    【解决方案1】:

    在应用程序资源中,提供一个名为“bottle_w_40@2x”的图像,这将是视网膜显示时最需要担心的事情。矩形不需要调整大小。

    【讨论】:

    • 只需添加具有该名称的相同图标或不同大小的图标?
    • 抱歉,我忘了指定,图标图像需要是第一张图像尺寸的两倍……所以如果 bottle_w_40.pg 是 100x100,那么 bottle_w_40@2x.png 将是 200x200。
    【解决方案2】:

    据我所知,该代码可以在视网膜显示器上运行。

    您可以在模拟器中进行测试。转到模拟器的硬件 > 设备菜单并选择“iPhone (Retina)”或“iPad (Retina)”。

    【讨论】:

    • 在模拟器上切换到 Iphone(retina),是的,它可以工作。这是否意味着它也可以在真实设备上运行?
    • 它可能会工作,但你需要找到一个真正的视网膜设备进行测试。
    猜你喜欢
    • 1970-01-01
    • 2013-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多