質問

I am using auto layout in my project when i trying to scroll a view and add constraints then it shows warning or errors please suggest me how to resolve it.

役に立ちましたか?

解決

Use scrollview and put your view inside that scrollview.

  • ScrollView - Apply constraints of x position,y position,leading & trailing space. don't give constraints of height and width of scrollview.
  • View - Apply constraints of x position,y position,leading & trailing space, width and height.

他のヒント

You first develope your whole layout. then put that layout inside a scrollview. Remember that a scrollview always takes only one layout and cannot take more then that. so remember to design your page in a manner that there is only one outer most layout and then put that whole layout inside ScrollView.

If you want only part of your page then put the elements that you want to scroll inside a layout and then put that layout inside a scrollView.

<ScrollView>
<LinearLayout>
//the whole page
</LinearLayout>
</ScrollView>


<LinearLayout>
//some elements
<ScrollView>
<LinearLayout>
//elements to be scrolled
</LinearLayout>
</ScrollView>
</LinearLayout>

Don't worry About it .Just make sure constraints are enough (no matter in your xib or code).SomeTimes I need to Conatraint my Views in scrollView which base on scrollView's subViews

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top