0
votes

I have a UIImageView in a Storyboard. The image used is square. The imageView width and height are equivalent. I want to take advantage of Autoresizing in Storyboard, so that on a small device the image is scaled down and on a large device the image is scaled up. When I test on a iPhone 5 the scaling is appropriate. However, when running on a iPad the results are different. The square is stretched, and this makes sense as the dimensions of the screen is different to the dimensions of the iPhone. How can I avoid this issue, is there a process in which I can scale the view as a whole up until the height is the same as the height of an iPad and then centre the view?

Note - The image has the same width and height and the content mode is set to 'Aspect Fit'

1
Without seeing your Autolayout constraints, it is really hard to help you solve this issue. If you set up a constraint on all imageviews to have the same width and a 1:1 ratio with themselves, it should be fine both on iPhones and iPads. - Dávid Pásztor
@DávidPásztor I have updated my question. I am only using the Autoresizing. The Image has the same width and height and the content mode is 'Aspect Fit'. - user6421669
If you set up the constraints I suggested it should work fine. - Dávid Pásztor
@DávidPásztor I have been messing with constraints all day, with no luck. Autoresizing has been working for me so far. Is there a different method/solution - user6421669
The best way to make an adaptive UI on iOS is by using Autolayout, so you should familiarize yourself with it, it's really helpful once you get the hang of it. - Dávid Pásztor

1 Answers

0
votes

Follow this procedure

1) add a view in which all your content will be added so now you going to use 2 views NewView[with Content] and baseView

enter image description here

now time to add constraints to newView Do like this for leading, trailing,bottom and top [adding wr hr component]

enter image description here

Result For iPad

enter image description here

result for iPhone

enter image description here