0

I am working on an app where I show in UIAlertView some icons appear in order to explan theirs use. I did that using:

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];

It works well, in simulator and in my iphone 3gs(no retina display). My dude is about the retina behavior. Images position will be different? Do I need to use some scaleFactor for the CGRectMake or position in the UIAlertview is absolute?

doxsi
  • 1,002
  • 19
  • 42

2 Answers2

1

In the application resources, provide an image named "bottle_w_40@2x", and that will be the main thing to worry about when it comes to retina display. The rectangles won't need to be resized.

CBredlow
  • 2,790
  • 2
  • 28
  • 47
  • simply adding the same icon with that name or a different size icons? – doxsi Aug 17 '12 at 18:06
  • Sorry, I forgot to specify, the icon image will need to be double the dimensions of the first image...so if bottle_w_40.pg is 100x100, then bottle_w_40@2x.png will be 200x200. – CBredlow Aug 17 '12 at 18:10
1

That code will work on a retina display, as far as I can tell.

You can test this in the simulator. Go to the simulator's Hardware > Device menu and choose “iPhone (Retina)” or “iPad (Retina)”.

rob mayoff
  • 375,296
  • 67
  • 796
  • 848