how do I use UIScrollView in Interface Builder?

后端 未结 17 1428
遇见更好的自我
遇见更好的自我 2020-11-28 19:52

While I\'ve used UIScrollView successfully in the past by manipulating it programmatically, I\'m having trouble getting it to work by setting it up exclusively

17条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-28 20:03

    I find out a more convenient way.

    1: Scale the size of the scroll view to contain all the ui inside it.

    2: Add a iboutlet of the scroll view.

    3: In viewDidLoad, save the frame.size of the scroll view.
    (e.g. _scrollSize = _scrollView.frame.size;)

    4: In viewWillAppear, set the contentSize by the CGSize you saved before.
    (e.g. _scrollView.contentSize = _scrollSize;)

    5: Done~

提交回复
热议问题