So I have this UIImageView with an image on top of it. When I’m using normal iPhone display, it shows inside the UIImageView exactly as it supposed to – in the UIImageView bounds, the problem is when I’m using retina display device, the image becomes big and doesn’t fit the UIImageView bounds, it goes all over the screen.
How can I fix this issue? I want the image in Retina display to fit inside the UIImageView size.
This is my code:
- (UIImage *)loadScreenShotImageFromDocumentsDirectory
{
UIImage * tempimage;
NSArray *sysPaths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES );
NSString *docDirectory = [sysPaths objectAtIndex:0];
NSString *filePath = [NSString stringWithFormat:@"%@/MeasureScreenShot.png", docDirectory];
tempimage = [[UIImage alloc] initWithContentsOfFile:filePath];
return tempimage;
}
- (void)viewDidLoad
{
// Setting the image
UIImage * Image = [self loadScreenShotImageFromDocumentsDirectory];
theImageView.frame = CGRectMake(0, 166, 290, 334);
theImageView.contentMode = UIViewContentModeCenter;
theImageView.image = Image;
}
Thank in advance!
Try setting the content mode to
UIViewContentModeScaleAspectFit