János János - 1 month ago 31
iOS Question

Where / when set contentOffset?

In UIViewController's lifecycle where is the best to set

contentOffest
of a
UIScrollView
?

If it is set in
viewDidLoad
or
viewWillAppear
, it has no effect. If in
viewDidAppear
then a small 'jump' will occur at beginning.

Tried with:

setContentOffset(CGPoint(x: some_value, y: 0), animated: false)


and:

contentOffset.x = some_value


I need to preload
contentOffset
with a previous scrolled position.

Anyway
UIScrollView
is a
UICollectionView
.

Answer

try to use it in viewDidLayoutSubviews