HUBViewControllerScrollHandler

@protocol HUBViewControllerScrollHandler <NSObject>

Protocol used to define custom scroll handlers for Hub Framework view controllers

Each feature can supply a scroll handler when it’s being registered with the Hub Framework (through HUBFeatureRegistry). This enables a feature to customize how scrolling is handled for all view controllers that will be created on its behalf.

  • Return whether scroll indicators should be shown in a view controller

    The Hub Framework will call this method when a view controller is being set up. The returned value will be used for both horizontal & vertical scroll indicators.

    Declaration

    Objective-C

    - (BOOL)shouldShowScrollIndicatorsInViewController:
        (HUBViewController *)viewController;

    Parameters

    viewController

    The view controller in question

  • Return whether the system’s automatic adjustment of content insets should be used for a view controller

    The Hub Framework will call this method when a view controller is being set up. The returned value will be assigned to its automaticallyAdjustsScrollViewInsets property, so see the documentation for that property on UIViewController for more information.

    Declaration

    Objective-C

    - (BOOL)shouldAutomaticallyAdjustContentInsetsInViewController:
        (HUBViewController *)viewController;

    Parameters

    viewController

    The view controller in question

  • Return the deceleration rate to use for scrolling in a view controller

    The Hub Framework will call this method when a view controller is being set up. The returned value will be assied to the decelerationRate property of its internal scroll view.

    Declaration

    Objective-C

    - (CGFloat)scrollDecelerationRateForViewController:
        (HUBViewController *)viewController;

    Parameters

    viewController

    The view controller in question

  • Return the content insets to use for a view controller

    The Hub Framework will call this method every time a view controller is being laid out, which is usually in response to that its view model has been changed. The returned value will be assigned to the contentInset property of its internal scroll view.

    Declaration

    Objective-C

    - (UIEdgeInsets)
    contentInsetsForViewController:(HUBViewController *)viewController
             proposedContentInsets:(UIEdgeInsets)proposedContentInsets;

    Parameters

    viewController

    The view controller in question

    proposedContentInsets

    The content insets that the Hub Framework is proposing will be used, which is computed in regards to the view’s current navigation bar height and the status bar height of the app.

  • React to that a scrolling event started in a view controller

    Declaration

    Objective-C

    - (void)scrollingWillStartInViewController:(HUBViewController *)viewController
                            currentContentRect:(CGRect)currentContentRect;

    Parameters

    viewController

    The view controller in question

    currentContentRect

    The rectangle of the currently visible content in the view controller’s scroll view

  • React to that a scrolling event ended in a view controller

    Declaration

    Objective-C

    - (void)scrollingDidEndInViewController:(HUBViewController *)viewController
                         currentContentRect:(CGRect)currentContentRect;

    Parameters

    viewController

    The view controller in question

    currentContentRect

    The rectangle of the currently visible content in the view controller’s scroll view

  • Return the target content offset for when scrolling ended in a view controller

    Declaration

    Objective-C

    - (CGPoint)
    targetContentOffsetForEndedScrollInViewController:
        (HUBViewController *)viewController
                                             velocity:(CGVector)velocity
                                         contentInset:(UIEdgeInsets)contentInset
                                 currentContentOffset:(CGPoint)currentContentOffset
                                proposedContentOffset:
                                    (CGPoint)proposedContentOffset;

    Parameters

    viewController

    The view controller in question

    velocity

    The current scrolling velocity

    contentInset

    The current content inset of the view controller’s scroll view

    currentContentOffset

    The current scrolling content offset

    proposedContentOffset

    The target content offset that the Hub Framework is proposing will be used

  • Return the content offset for displaying a component at a certain scroll position.

    Declaration

    Objective-C

    - (CGPoint)
    contentOffsetForDisplayingComponentAtIndex:(NSUInteger)componentIndex
                                scrollPosition:(HUBScrollPosition)scrollPosition
                                  contentInset:(UIEdgeInsets)contentInset
                                   contentSize:(CGSize)contentSize
                                viewController:(HUBViewController *)viewController;

    Parameters

    componentIndex

    The index of the component to display.

    scrollPosition

    The position to display the component at.

    contentInset

    The current content inset of the view controller’s scroll view

    contentSize

    The current content size of the view controller’s scroll view

    viewController

    The view controller in question.