Home > DeveloperSection > Forums > How to display image without streach in UIScrollview?
sandy taylor
sandy taylor

Total Post:46

Posted on    February-10-2016 11:31 PM

 iPhone iPhone  Ios  Objective C 

 1 Reply(s)
 620  View(s)
Rate this:
I have an image in our scrollview but the image is not displaying in its correct dimension means displaying streatched image. So my problem is how can I prevent image being stretched in our UIScrollView controller.
I already used AspectFill but it's not working.
Please suggest me how can I solve this issue.

Tarun Kumar

Total Post:214

Posted on    February-20-2016 4:12 AM

If you want to prevent your image being stretch in UIScrollView, then before adding the image view as subview of scrollview don't set the image view size according to the images size.
I think you are setting your UIImageView frame size according to your scrollview size or app view size, if you are doing same as like I am thinking then don't do it.
Use it like this:
UIImage *img = [UIImage imageNamed:@"img1.jpg"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:img];
[self.scrollview addSubview:self.imageView];
I think the above example is sufficient for you to understand the problem.

Don't want to miss updates? Please click the below button!

Follow MindStick