Load mesh (high-quality) images programmatically (on buttons)

I have a problem that I just could not understand. I have an application that will take a picture in front and one from the rear camera, and then combine them.

GroupCam Application Name

However, I have a problem when my UIButtons won't load as retina images from the start. If I installed them as @ 2x in the interface builder, they look in high quality, but as soon as I reboot them programmatically, lower versions will appear instead.

This is due to the fact that after the image is taken and the screen changes the image of the button, but when the user presses the "Back" button, the camera icons will look awful (because low-quality versions are being downloaded).

Please check the following pictures:

Initial screen: Only the top right button is displayed, because I check the flash value of the camera and “download” the corresponding image programmatically.

First screen

Second screen: The user switched to another screen and returned to the first, all buttons were reset, and now they look distorted.

Second screen

If anyone knows why this is happening, I would really appreciate it!

Thank.

Edit:

This is how I upload images.

[self.flashButton setImage:[UIImage imageNamed:@"flashOff"] 
                          forState:UIControlStateNormal];

I read somewhere on the Internet that this will automatically download the most suitable version of the image.

I also tried this, but the result is the same:

[self.takeButton setImage:[UIImage imageNamed:@"takePhoto.png"] forState:UIControlStateNormal];
+5
source share
3 answers

, . iOS, , ( iPad 2, ), , . , . , . UIImage imageNamed: @ "ImageName", , ! !

+3

, , , . , - , hi-res , .

,

<uibutton_superview>.layer.shouldRasterize = YES;

- , .

+4

, .

. Image.png image@2x.png , . image.png image@2x.png. .jpg , .

+3

All Articles