UIScrollView and setContentOffset

后端 未结 2 1613
我在风中等你
我在风中等你 2021-02-04 09:59

My question is about this method:
(void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated

I have read the documentation, but i don\'t unde

2条回答
  •  自闭症患者
    2021-02-04 10:07

    As mentioned in documentation.

    Scrolling to a Specific Offset

    Scrolling to a specific top-left location (the contentOffset property) can be accomplished in two ways. The setContentOffset:animated: method scrolls the content to the specified content offset. If the animated parameter is YES, the scrolling will animate from the current position to the specified position at a constant rate. If the animated parameter is NO, the scrolling is immediate and no animation takes place. In both cases, the delegates scrollViewDidScroll: messages. If animation is disabled, or if you set the content offset by setting the contentOffset property directly, the delegate receives a single scrollViewDidScroll: message. If animation is enabled, then the delegate receives a series of scrollViewDidScroll: messages as the animation is in progress. When the animation is complete, the delegate receives a scrollViewDidEndScrollingAnimation: message.

    i.e. In simple words if you want to scroll UIScrollView programatically by passing scrolling position values i.e. how much amount to scroll, you can use this method.

    This method also calls delegate scrollViewDidScroll: i.e. delegate method of UIScrollView class through which you can maintain the amount of scrolling of UIScrollView.

提交回复
热议问题