0
votes

This is my view hierarchy,

UIView
 UIScrollView
   UIView
     UIView
     UIButton
   UIView
     UIView
     UIButton
   UIView
     UIView
     UIButton
   ...

I have set Leading / Trailing and Top/Bottom space constraints to UIScrollView. But don't know why, inside contents are more than UIScrollViews width? Its moving like all around (I don't know how to explain this?)... Is this an issue of contentSize? If so, that I haven't set any where. Is it required to set it? Or any constraints I missed to add?

P.S. I'm pretty new to Autolayout.

1
did u constraint the scroll view width and height ?Teja Nandamuri
if inside contents are more than the scroll view width, then you might missing the constrainst setup for the inside contentsTeja Nandamuri
Add a UIView inside Scrollview to hold all other UIViews inside it.Bista
@the_UB, is this the best way?Hemang
For me? Yes. Inside Scroll View add a UIView and Contraint its all sides to the Scroll View. The added UIView is called Content View, as it will contain all the content of Scroll View.Bista

1 Answers

1
votes

Actually I also face same issue earlier. I resolved the issue by using the tableview instead of scrollview. You can use only one row in tableview and add content there. Tableview easily supports the auto layout.