dancingbush
dancingbush

Reputation: 2281

Autolayout Rendering inconsistently across devices

I have a series of views each containing a scrollview wrapping various subviews i.e. Collection views, Labels, imagview. I am using auto layout for the first time and some views render fine on some devices but not on others, I have attached previews of views on iPhone 4s, 5, and 6.

Iphone 5 Scrollview wrapping image view and label view is to far right iphone 5 scrollview wrapping collection view fine iphone 5 scrollview wrapping zoomable image fine Ssame image here for iPhone 4 top blue IV cut short iphone 6 Scrollview wrapping image view and label view is fine iphone6 Scrollview wrapping content view cut short to the right iphone 6 scrollview wrapping zoomable image fine

In particular I am not sure how the alignment of the History views appears off centre in iPhone 5 and 4 but fine in 6, and the collection view in iPhone 6 appears cut sort on the right side but not for iPhone 5,4, and lastly how the blue image with label 'Image Title' on top of the zoomable image on iPhone 4s appears to be cut short. I would of thought a error in autolayout would of been consistent across devices ?

Any input appreciated.

Upvotes: 1

Views: 247

Answers (2)

erenkabakci
erenkabakci

Reputation: 442

Try to give consistent constraints. Looks like you are just doing leading and top space to superview and maybe you are adding width and height constraints to avoid misplaced views. Try to think like you are doing autoresizing masks before autolayouts. Either try to keep ratio or expand with the container with trailing and bottom space constraints.

Upvotes: 1

Sandy Chapman
Sandy Chapman

Reputation: 11341

It looks like you're setting absolute widths on some elements. Instead you should be setting distance to the parent UIView's edges. I.e. trailing/leading space to container.

Upvotes: 1

Related Questions