MDCAppBarNavigationControllerDelegate

@protocol MDCAppBarNavigationControllerDelegate <UINavigationControllerDelegate>

Defines the events that an MDCAppBarNavigationController may send to a delegate.

  • Informs the receiver that the given App Bar will be added as a child of the given view controller.

    This event is primarily intended to allow any configuration or theming of the App Bar to occur before it becomes part of the view controller hierarchy.

    By the time this event has fired, the navigation controller will already have attempted to infer the tracking scroll view from the provided view controller.

    Note

    This method will only be invoked if a new App Bar instance is about to be added to the view controller. If a flexible header is already present in the view controller, this method will not be invoked.

    Declaration

    Objective-C

    - (void)appBarNavigationController:
                (nonnull MDCAppBarNavigationController *)navigationController
           willAddAppBarViewController:
               (nonnull MDCAppBarViewController *)appBarViewController
               asChildOfViewController:(nonnull UIViewController *)viewController;
  • Asks the receiver to determine the tracking scroll view for a given view controller.

    If this method is not implemented, the app bar navigation controller will extract the first UIScrollView instance in the view controller’s view hierarchy using a depth-first view traversal.

    Implement this method when you need to change the default behavior of the tracking scroll view detection. The suggested tracking scroll view will contain the scroll view that would have been used; you can ignore this value.

    Your implementation will likely return the suggested tracking scroll view by default, with custom logic being implemented for specific view controllers that require it.

    Note

    This method will only be invoked if a new App Bar instance is about to be added to the view controller. If a flexible header is already present in the view controller, this method will not be invoked.

    Declaration

    Objective-C

    - (nullable UIScrollView *)
             appBarNavigationController:
                 (nonnull MDCAppBarNavigationController *)navigationController
    trackingScrollViewForViewController:(nonnull UIViewController *)viewController
            suggestedTrackingScrollView:(nullable UIScrollView *)scrollView;

    Parameters

    navigationController

    The app bar navigation controller instance that owns the view controller.

    viewController

    The view controller for which the tracking scroll view should be determined.

    scrollView

    A suggested tracking scroll view. This is the first UIScrollView instance detected by a depth-first view traversal of @c viewController’s view hierarchy. This suggestion can be ignored.

    Return Value

    The tracking scroll view to be used for this view controller. If nil is returned then no tracking scroll view will be set.