IGListSectionController


@interface IGListSectionController : NSObject

The base class for section controllers used in a list. This class is intended to be subclassed.

  • Returns the number of items in the section.

    Note

    The count returned is used to drive the number of cells displayed for this section controller. The default implementation returns 1. Calling super is not required.

    Declaration

    Objective-C

    - (NSInteger)numberOfItems;

    Swift

    func numberOfItems() -> Int

    Return Value

    A count of items in the list.

  • The specific size for the item at the specified index.

    Note

    The returned size is not guaranteed to be used. The implementation may query sections for their layout information at will, or use its own layout metrics. For example, consider a dynamic-text sized list versus a fixed height-and-width grid. The former will ask each section for a size, and the latter will likely not. The default implementation returns size zero. Calling super is not required.

    Declaration

    Objective-C

    - (CGSize)sizeForItemAtIndex:(NSInteger)index;

    Swift

    func sizeForItem(at index: Int) -> CGSize

    Parameters

    index

    The row index of the item.

    Return Value

    The size for the item at index.

  • Return a dequeued cell for a given index.

    Note

    This is your opportunity to do any cell setup and configuration. The infrastructure requests a cell when it will be used on screen. You should never allocate new cells in this method, instead use the provided adapter to call one of the dequeue methods on the IGListCollectionContext. The default implementation will assert. You must override this method without calling super.

    Declaration

    Objective-C

    - (nonnull __kindof UICollectionViewCell *)cellForItemAtIndex:(NSInteger)index;

    Swift

    func cellForItem(at index: Int) -> UICollectionViewCell

    Parameters

    index

    The index of the requested row.

    Return Value

    A configured UICollectionViewCell subclass.

  • Updates the section controller to a new object.

    Note

    When this method is called, all available contexts and configurations have been set for the section controller. This method will only be called when the object instance has changed, including from nil or a previous object. Calling super is not required.

    Declaration

    Objective-C

    - (void)didUpdateToObject:(nonnull id)object;

    Swift

    func didUpdate(to object: Any)

    Parameters

    object

    The object mapped to this section controller.

  • Tells the section controller that the cell at the specified index path was selected.

    Note

    The default implementation does nothing. Calling super is not required.

    Declaration

    Objective-C

    - (void)didSelectItemAtIndex:(NSInteger)index;

    Swift

    func didSelectItem(at index: Int)

    Parameters

    index

    The index of the selected cell.

  • Tells the section controller that the cell at the specified index path was deselected.

    Note

    The default implementation does nothing. Calling super is not required.

    Declaration

    Objective-C

    - (void)didDeselectItemAtIndex:(NSInteger)index;

    Swift

    func didDeselectItem(at index: Int)

    Parameters

    index

    The index of the deselected cell.

  • Tells the section controller that the cell at the specified index path was highlighted.

    Note

    The default implementation does nothing. Calling super is not required.

    Declaration

    Objective-C

    - (void)didHighlightItemAtIndex:(NSInteger)index;

    Swift

    func didHighlightItem(at index: Int)

    Parameters

    index

    The index of the highlighted cell.

  • Tells the section controller that the cell at the specified index path was unhighlighted.

    Note

    The default implementation does nothing. Calling super is not required.

    Declaration

    Objective-C

    - (void)didUnhighlightItemAtIndex:(NSInteger)index;

    Swift

    func didUnhighlightItem(at index: Int)

    Parameters

    index

    The index of the unhighlighted cell.

  • The view controller housing the adapter that created this section controller.

    Note

    Use this view controller to push, pop, present, or do other custom transitions.

    Warning

    It is considered very bad practice to cast this to a known view controller and call methods on it other than for navigations and transitions.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) UIViewController *viewController;

    Swift

    weak var viewController: UIViewController? { get }
  • A context object for interacting with the collection.

    Use this property for accessing the collection size, dequeuing cells, reloading, inserting, deleting, etc.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) id<IGListCollectionContext>
        collectionContext;

    Swift

    weak var collectionContext: ListCollectionContext? { get }
  • Returns the section within the list for this section controller.

    Note

    This value also relates to the section within a UICollectionView that this section controller’s cells belong. It also relates to the -[NSIndexPath section] value for individual cells within the collection view.

    Declaration

    Objective-C

    @property (readonly, assign, nonatomic) NSInteger section;

    Swift

    var section: Int { get }
  • Returns YES if the section controller is the first section in the list, NO otherwise.

    Declaration

    Objective-C

    @property (readonly, assign, nonatomic) BOOL isFirstSection;

    Swift

    var isFirstSection: Bool { get }
  • Returns YES if the section controller is the last section in the list, NO otherwise.

    Declaration

    Objective-C

    @property (readonly, assign, nonatomic) BOOL isLastSection;

    Swift

    var isLastSection: Bool { get }
  • The margins used to lay out content in the section controller.

    See

    -[UICollectionViewFlowLayout sectionInset].

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) UIEdgeInsets inset;

    Swift

    var inset: UIEdgeInsets { get set }
  • The minimum spacing to use between rows of items.

    See

    -[UICollectionViewFlowLayout minimumLineSpacing].

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGFloat minimumLineSpacing;

    Swift

    var minimumLineSpacing: CGFloat { get set }
  • The minimum spacing to use between items in the same row.

    See

    -[UICollectionViewFlowLayout minimumInteritemSpacing].

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGFloat minimumInteritemSpacing;

    Swift

    var minimumInteritemSpacing: CGFloat { get set }
  • The supplementary view source for the section controller. Can be nil.

    Note

    You may wish to return self if your section controller implements this protocol.

    Declaration

    Objective-C

    @property (readwrite, nonatomic, nullable) id<IGListSupplementaryViewSource>
        supplementaryViewSource;

    Swift

    weak var supplementaryViewSource: ListSupplementaryViewSource? { get set }

    Return Value

    An object that conforms to IGListSupplementaryViewSource or nil.

  • An object that handles display events for the section controller. Can be nil.

    Note

    You may wish to return self if your section controller implements this protocol.

    Declaration

    Objective-C

    @property (readwrite, nonatomic, nullable) id<IGListDisplayDelegate>
        displayDelegate;

    Swift

    weak var displayDelegate: ListDisplayDelegate? { get set }

    Return Value

    An object that conforms to IGListDisplayDelegate or nil.

  • An object that handles working range events for the section controller. Can be nil.

    Note

    You may wish to return self if your section controller implements this protocol.

    Declaration

    Objective-C

    @property (readwrite, nonatomic, nullable) id<IGListWorkingRangeDelegate>
        workingRangeDelegate;

    Swift

    weak var workingRangeDelegate: ListWorkingRangeDelegate? { get set }

    Return Value

    An object that conforms to IGListWorkingRangeDelegate or nil.

  • An object that handles scroll events for the section controller. Can be nil.

    Note

    You may wish to return self if your section controller implements this protocol.

    Declaration

    Objective-C

    @property (readwrite, nonatomic, nullable) id<IGListScrollDelegate>
        scrollDelegate;

    Swift

    weak var scrollDelegate: ListScrollDelegate? { get set }

    Return Value

    An object that conforms to IGListScrollDelegate or nil.