I'm trying to get an image from a URL to view it on an iPhone and an iPhone Retina. The problem is that iPhone is displayed correctly but Retina is blurred. The image has a size of 100x100 at 326dpi (size retina).
I'm doing it correctly?
- (void)viewDidLoad
{
[super viewDidLoad];
double scaleFactor = [UIScreen mainScreen].scale;
NSURL *imageURL = [NSURL URLWithString:@"http://s419999211.mialojamiento.es/img/bola.png"];
if (scaleFactor == 2){
// @2x
NSLog(@"Estoy cargando la imágen retina");
NSData * imageData = [NSData dataWithContentsOfURL:imageURL];
image = [UIImage imageWithData:imageData];
NSLog(@"Width: %f Height: %f",image.size.width,image.size.height);
yourImageView = [[UIImageView alloc] initWithImage:image];
} else {
// @1x
NSLog(@"Estoy cargando la imágen normal");
NSData * imageData = [NSData dataWithContentsOfURL:imageURL];
image = [UIImage imageWithData:imageData];
imagenScalada = [UIImage imageWithCGImage:[image CGImage] scale:1.0 orientation:UIImageOrientationUp];
NSLog(@"Width: %f Height: %f",imagenScalada.size.width,imagenScalada.size.height);
yourImageView = [[UIImageView alloc] initWithImage:imagenScalada];
}
[self.view addSubview:yourImageView];
}
Thank you!
iPhone Normal iPhone Retina