Bashir Sidani Bashir Sidani - 10 months ago 33
iOS Question

how to drag UIScrollView to the very right depending on its childs

This is a very simple question,
I have a UIScrollView where I am setting childView horizontally from left to right. each time I am adding a new view, I want my ScrollView to scroll to the right so that the newly added view is seen on the screen.


When you add a new view you need to first increase the scroll view's content size.

scrollView.contentSize = CGSize(width: childV1.frame.width + childV2.frame.width, height: scrollView.contentSize.height)

Then you should be able to call scrollRectToVisible and pass in the most recently added child view's frame.