UICollectionView automatically scroll to bottom when screen loads

后端 未结 9 2105
Happy的楠姐
Happy的楠姐 2021-02-05 02:44

I\'m trying to figure out how to scroll all the way to the bottom of a UICollectionView when the screen first loads. I\'m able to scroll to the bottom when the status bar is tou

9条回答
  •  故里飘歌
    2021-02-05 03:04

    Just to elaborate on my comment.

    viewDidLoad is called before elements are visual so certain UI elements cannot be manipulated very well. Things like moving buttons around work but dealing with subviews often does not (like scrolling a CollectionView).

    Most of these actions will work best when called in viewWillAppear or viewDidAppear. Here is an except from the Apple docs that points out an important thing to do when overriding either of these methods:

    You can override this method to perform additional tasks associated with presenting the view. If you override this method, you must call super at some point in your implementation.

    The super call is generally called before custom implementations. (so the first line of code inside of the overridden methods).

提交回复
热议问题