iOS Developer Library — Prerelease

Developer

UIKit Framework Reference UIScrollViewDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

UIScrollViewDelegate

The methods declared by the UIScrollViewDelegate protocol allow the adopting delegate to respond to messages from the UIScrollView class and thus respond to, and in some affect, operations such as scrolling, zooming, deceleration of scrolled content, and scrolling animations.

  • Asks the delegate for the view to scale when zooming is about to occur in the scroll view.

    Declaration

    Swift

    optional func viewForZoomingInScrollView(_ scrollView: UIScrollView) -> UIView?

    Objective-C

    - (UIView * _Nullable)viewForZoomingInScrollView:(UIScrollView * _Nonnull)scrollView

    Parameters

    scrollView

    The scroll-view object displaying the content view.

    Return Value

    A UIView object that will be scaled as a result of the zooming gesture. Return nil if you don’t want zooming to occur.

    Availability

    Available in iOS 2.0 and later.

  • Tells the delegate that zooming of the content in the scroll view is about to commence.

    Declaration

    Swift

    optional func scrollViewWillBeginZooming(_ scrollView: UIScrollView, withView view: UIView?)

    Objective-C

    - (void)scrollViewWillBeginZooming:(UIScrollView * _Nonnull)scrollView withView:(UIView * _Nullable)view

    Parameters

    scrollView

    The scroll-view object displaying the content view.

    view

    The view object whose content is about to be zoomed.

    Discussion

    This method is called at the beginning of zoom gestures and in cases where a change in zoom level is to be animated. You can use this method to store state information or perform any additional actions prior to zooming the view’s content.

    Availability

    Available in iOS 3.2 and later.

  • Tells the delegate when zooming of the content in the scroll view completed.

    Declaration

    Swift

    optional func scrollViewDidEndZooming(_ scrollView: UIScrollView, withView view: UIView?, atScale scale: CGFloat)

    Objective-C

    - (void)scrollViewDidEndZooming:(UIScrollView * _Nonnull)scrollView withView:(UIView * _Nullable)view atScale:(CGFloat)scale

    Parameters

    scrollView

    The scroll-view object displaying the content view.

    view

    The view object representing that part of the content view that needs to be scaled.

    scale

    The scale factor to use for scaling; this value must be between the limits established by the UIScrollView properties maximumZoomScale and minimumZoomScale.

    Discussion

    The scroll view also calls this method after any “bounce” animations. It also calls this method after animated changes to the zoom level and after a zoom-related gesture ends (regardless of whether the gesture resulted in a change to the zoom level).

    Availability

    Available in iOS 2.0 and later.

  • Tells the delegate that the scroll view’s zoom factor changed.

    Declaration

    Swift

    optional func scrollViewDidZoom(_ scrollView: UIScrollView)

    Objective-C

    - (void)scrollViewDidZoom:(UIScrollView * _Nonnull)scrollView

    Parameters

    scrollView

    The scroll-view object whose zoom factor changed.

    Availability

    Available in iOS 3.2 and later.