scrollview has ambiguous content width on Xcode 6

11,746

Solution 1

I observed its fix in XCode 7.3 and it is just 10 sec work. I made a video on it. Check here:

https://www.youtube.com/watch?v=yETZKqdaPiI

All you have to do, add a subview to UIScrollView with same width and height. Then select ViewController and press Reset to suggested constraint. Please check video for clear understanding.

Thanks

Solution 2

This is because you are not providing enough constraints so that Xcode can find Width of your scroll view. You can see on your screen there isn't any constraints that can be satisfied to find width of scroll view.

You can do it by providing leading and trailing space of Image view which contains fix width. It also can be done with any other views. But i will prefer control which contains fix Height & Width So there isn't require to set hugging priority or Compress resistance.

Solution 3

Put everything in a View and that View put inside a ScrollView.

Editor -> Embed in -> View

Solution 4

The solutions is:

  1. You have a UIImageView at the top. You set the width of the UIImageView to be the same as the width of the root view of the UIViewController

  2. You set the leading and trailing space of the UIImageView to the UIScrollView to be both 0

  3. You set the height of the UIImageView to be the height you want the image to be. And then you set the view mode of the UIImageView to be 'Aspect fit'.

Share:
11,746
Piero
Author by

Piero

Updated on June 30, 2022

Comments

  • Piero
    Piero almost 2 years

    I can't understand how can I solve this auto layout problem, i have this View:

    enter image description here

    There is an UIScrollView with the elements you see in the View, but the View gives me this warning:

    scrollview has ambiguous content width
    

    I can't understand how to solve this problem, I want the the view is for the full screen size, and I want that the width will be the screen width, how I can solve it?

  • Geekoder
    Geekoder over 9 years
    Anything you did to resolve this issue. My content is already embeded in a UIView and this UIView is added to the UIScrollView. I get ambiguity issues for both height and width in scrollview. Any solution ?