2012-08-17 350 views
0

我正在研究一个应用程序,在UIAlertView中显示一些图标以解释它们的用法。 我这样做,使用:UIAlertView中的图像:CGRectMake在视网膜和非视网膜中iPhone

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中的位置是绝对的?

回答

1

在应用程序资源中,提供名为“bottle_w_40 @ 2x”的图像,并且在涉及视网膜显示时,这将是主要问题。矩形不需要调整大小。

+0

只需添加与该名称或不同大小的图标相同的图标? – doxsi 2012-08-17 18:06:25

+0

对不起,我忘了指定,图标图片需要是第一张图片尺寸的两倍......所以如果bottle_w_40.pg是100x100,那么[email protected]会是200x200。 – CBredlow 2012-08-17 18:10:03

1

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

你可以在模拟器中测试这个。转到模拟器的硬件>设备菜单,然后选择“iPhone(视网膜)”或“iPad(视网膜)”。

+0

在模拟器上切换到iPhone(视网膜),是的它的工作原理。这是否意味着它也可以在真实设备上运行? – doxsi 2012-08-17 18:05:33

+0

它可能会工作,但你需要找到一个真正的视网膜设备来测试。 – 2012-08-17 18:07:22

相关问题