Question

I have an image view and underneath it a webview. They have a small vertical distance between them when viewed on a 3.5 inch screen but when I apply retina 4 Form Factor the image view expands (the actual image size is fixed) so that there appears to be a big gap between it and the webview underneath. Also there is a gap between the image view and the top of the screen. I have experimented with constraints but don't seem to be able to alter things so that it is the webview which expands vertically, leaving a small gap between it and the imageview.

Was it helpful?

Solution

You need to set UIImageView autosizing property:

enter image description here

OR you can set it programatically using

imageView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

If this doesn't solve your problem, you have two possible solutions for this. Listed below:

1.In the 'Simulated Metrics' section of UIVIew's attributes inspector, you can choose between 3,5" or 4" sizes. Choose 3,5", and make your views and subviews resizable .This will make it automatically scale your view to fit iPhone 5's screen.

2.OR you can make use of Auto Layout (constraints) with the deployment target of iOS 6+.

Hope this will solve the issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top