HUBComponentChildDelegate
@protocol HUBComponentChildDelegate <NSObject>
Delegate protocol used to send events related to a component’s children back to the Hub Framework
You don’t implement this protocol yourself. Instead, you \@synthesize your component’s childDelegate
property, and may choose to send any of these methods to it to notify it of events, as well as creating
child component instances.
It’s definitely recommended to use this protocol as much as possible when using child components, since you can leverage the framework’s built-in capabilities for selection, image loading & other events.
-
Return a child component for a given model
You may choose to use this method to create components to use to represent any child component models that you wish to render in your component. Note that it is not required to use this method to create views or other visual representation for child components, but it’s a convenient way - especially for components that wish to be truly dynamic with which child components they support.
Components created this way are retained and managed by the Hub Framework, and reused whenever they are sent the
prepareViewForReuse
message. Selection for them is also automatically handled, just like it is for root components.Declaration
Objective-C
- (nonnull id<HUBComponent>) component:(nonnull id<HUBComponentWithChildren>)component childComponentForModel:(nonnull id<HUBComponentModel>)childComponentModel;
Parameters
component
The parent component
childComponentModel
The model to return a child component for
Return Value
A component that was either newly created, or reused - if an inactive component of the same type was available. The component will have its view loaded and resized according to its parent and the component’s
preferredViewSize
, and will be configured according to the passedchildComponentModel
. -
Notify the Hub Framework that a component is about to display a child component at a given index
If your component has nested child components, you should call this method every time a child is about to appear on the screen, to enable the Hub Framework to load images and perform other setup work for it.
Declaration
Objective-C
- (void)component:(nonnull id<HUBComponentWithChildren>)component willDisplayChildAtIndex:(NSUInteger)childIndex view:(nonnull UIView *)childView;
Parameters
component
The parent component
childIndex
The index of the child component that is about to be displayed
childView
The view of the child component that is about to be displayed
-
Notify the Hub Framework that a component has stopped displaying a child component at a given index
Declaration
Objective-C
- (void)component:(nonnull id<HUBComponentWithChildren>)component didStopDisplayingChildAtIndex:(NSUInteger)childIndex view:(nonnull UIView *)childView;
Parameters
component
The parent component
childIndex
The index of the child component that is no longer being displayed
childView
The view of the child component that is no longer displayed
-
Notify the Hub Framework that a custom child component view was selected
If you implement your child components as custom
UIViews
(that is, not usingHUBComponent
implementations resolved usingchildDelegate
), you can call this method to have the Hub Framework perform selection handling on behalf of your child component.If you are not using custom views, but rather nested
HUBComponent
implementations, you don’t have to call this method, as the Hub Framework will automatically manage selection for those components.Declaration
Objective-C
- (void)component:(nonnull id<HUBComponentWithChildren>)component childWithCustomViewSelectedAtIndex:(NSUInteger)childIndex customData:(nullable NSDictionary<NSString *, id> *) customData;
Parameters
component
The parent component
childIndex
The index of the child component that was selected
customData
Any custom data to use when the selection is handled. Will be available on the
HUBActionContext
passed to any actions handling the selection.