tranvutuan
tranvutuan

Reputation: 6109

how to do scroll in scrollview

My scroll view is containing 4 views. Below are the first three in my scroll view enter image description here

My goal : i would like to scroll so that my scroll view will show the second + the third + the fourth view ( the first view will be off )

Question : how can i do that

Right now when i scroll, i am getting

enter image description here

Upvotes: 0

Views: 117

Answers (1)

RileyE
RileyE

Reputation: 11084

From the looks of things, it seems as though you aren't adding the other views, or you're not adding them in the proper position.

In order to have a UIScrollView work, you'll need to set the contentSize and frame properties and position the subviews as if it were one big map. Say you had three 200x200 views you wanted to add, you would set their individual frame properties to (0, 0, 200, 200), (200, 0, 200, 200), (400, 0, 200, 200), if you wanted them side by side. Then you would need the UIScrollView's contentSize property set to (600, 200) in order to have it scroll through all of it.

If this isn't what you're looking for, please clarify your question.

Upvotes: 3

Related Questions