ClockWise
ClockWise

Reputation: 1519

Set UIScrollView.setContentOffset without scrolling?

I have a UIScrollView which shows a range of different plots. I want the UIScrollView to scroll from LEFT to RIGHT, so I want to set the ContentOffset of the UIScrollView to the "end" of the ContentOffset. I do it like this, which works:

var point = CGPointMake(scrollView.contentSize.width - scrollView.frame.size.width, 0)
scrollView.setContentOffset(point, animated: true)

However, this means that it will scroll the entire offset to that specific point, which results in the user seeing all the plots flashing by. Of course I would just like the UIScrollView to start at that particular point without scrolling to it, but I can't figure out what to do. If I set animated: false the scrolling stops working altogether.

Any help will be highly appreciated!

Upvotes: 0

Views: 2635

Answers (1)

Tushar
Tushar

Reputation: 3052

You have to use the same method with 'false' but make sure you set the contentSize of the scrollview before you make the above call for scrolling to take effect.

Upvotes: 1

Related Questions