I wanted to know how should I use high res images in iOS4 sdk using UIImaageView.
blackBox = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"alert_bg.png"]];
blackBox.frame = CGRectMake(98.0f, 310.0f, 573.0f, 177.0f);
When I use this code I get strange results… the image does not get the correct size. It is looking very big on iPhone 4 screen.
Should I use 326 ppi images?
I have read http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/SupportingResolutionIndependence/SupportingResolutionIndependence.html this but I am very confuse.
Thanks
Saurabh
The key thing to understand about supporting the Retina Display is that, in your code, the screen is always 320×480. You don’t need to double the resolution of anything but your image resources themselves. In this case, you just need to put two resources in your app bundle: an
alert_bg.pngthat fits on a 320×480 screen—in this case, I’d guess that’d be 286×88—and analert_bg@2x.png, exactly double the size of the other, that fits on a 640×960 one. If you ask UIKit for[UIImage imageNamed:@"alert_bg"], it’ll automatically pick the correct-resolution resource for the current screen.