Button resizing issues

So I have a button with an image attached to it. It is supposed to resize maintaining its aspect ratio.


The problem is, that when the screen is flipped, the button background is resizing instead of the image itself (the image is maintaining the same size as in portrait mode).


What's strange is that I've had this work seemingly random for some images, while not for others. I'm sure I'm doing something different, I just can't find the inconsistency.


My image constraints are usually: trailing/leading/bottom to the subview, and vertical distance to some content (ex: label).


Any help would be greatly appreciated.

Are you sure you have no constraint on image width and height ?

Unless image constrains are different than the button constraints, then I'm sure.

Can you compare an image that works with one that doesn't ?

- is it the same file type (png, …)

- how did you define scaling in button attribute inspector ?

-Both the images are png. The only difference I can really tell you between the images, is that ones default dimensions are: W: 317, H: 273 (the one that does not work). The other image has dimensions of: W: 326, H: 178 (the one that does work).


-The attribute inspector has all defaults, with content mode at 'scale to fill' (I tried 'scale to fit' but it didn't make a difference).

In the Attributes inspector of the buttons, in the view panel, there is a Autorisize subview.


Is it checked bor both buttons ?

It is checked for both.

dimensions are: W: 317, H: 273 (the one that does not work). The other image has dimensions of: W: 326, H: 178 (the one that does work)


Could it be that the height of image that does not work is too much to fit in the control once it is tilted ?

What are the sizes of the control button in both orientations ?

Its not letting me see the oriented size, because I have a scroll subview. But I did change the height of the button/image (distorting the image a bit), and it's still resizing as before, changing the image back to a proper aspect ratio.

Could you post the code on gitHub ?

I would, but its actually not reliant on any code, not the button resizing anyway. It's all done in storyboard.

Well.


So to help, one need to have a look at all the constraints defined, very precisely. Autolayout is so sensitive to tiny details, that it's difficult to say precisely what's going on without thorough inspection.


Good luck so.

Thanks for your time thus far. I'll look at the constraints, and might post some pictures/details sometime soon.

Button resizing issues
 
 
Q