ReloadableViewLayoutAdapter

open class ReloadableViewLayoutAdapter: NSObject, ReloadableViewUpdateManagerDelegate

Manages background layout for reloadable views, including UICollectionView and UITableView.

Set it as a UICollectionView or UITableView’s dataSource and delegate.

  • The current layout arrangement. Must be accessed from the main thread only.

    Declaration

    Swift

    open internal(set) var currentArrangement = [Section<[LayoutArrangement]>]()
  • The queue that layouts are computed on.

    Declaration

    Swift

    public let backgroundLayoutQueue: OperationQueue =
  • Logs messages.

    Declaration

    Swift

    open var logger: ((String) -> Void)? = nil
  • Undocumented

    Declaration

    Swift

    open class ReloadableViewLayoutAdapter: NSObject, ReloadableViewUpdateManagerDelegate
  • Reloads the view with the new layout.

    If synchronous is false and the view doesn’t already have data loaded and no batch updates are provided, then it will incrementally insert cells into the reloadable view as layouts are computed to increase user perceived performance for large collections. Pass an empty BatchUpdates object if you wish to disable this optimization for an asynchronous reload of an empty collection.

    Declaration

    Swift

    open func reload<T: Collection, U: Collection>(
            width: CGFloat? = nil,
            height: CGFloat? = nil,
            synchronous: Bool = false,
            batchUpdates: BatchUpdates? = nil,
            layoutProvider: @escaping (Void) -> T,
            completion: (() -> Void)? = nil) where U.Iterator.Element == Layout, T.Iterator.Element == Section<U>

    Parameters

    width

    The width of the layout’s arrangement. Nil means no constraint. Default is nil.

    height

    The height of the layout’s arrangement. Nil means no constraint. Default is nil.

    synchronous

    If true, reload will not return until the operation is complete. Default is false.

    batchUpdates

    The updates to apply to the reloadable view after the layout is computed. If nil, then all data will be reloaded. Default is nil.

    layoutProvider

    A closure that produces the layout. It is called on a background thread so it must be threadsafe.

    completion

    A closure that is called on the main thread when the operation is complete.

  • Reloads the view with a precomputed layout. It must be called on the main thread.

    This is useful if you want to precompute the layout for this collection view as part of another layout. One example is nested collection/table views (see NestedCollectionViewController.swift in the sample app).

    Declaration

    Swift

    open func reload(arrangement: [Section<[LayoutArrangement]>])
  • Undocumented

    Declaration

    Swift

    open class ReloadableViewLayoutAdapter: NSObject, ReloadableViewUpdateManagerDelegate
  • Undocumented

    Declaration

    Swift

    open class ReloadableViewLayoutAdapter: NSObject, ReloadableViewUpdateManagerDelegate
  • Undocumented

    Declaration

    Swift

    open class ReloadableViewLayoutAdapter: NSObject, ReloadableViewUpdateManagerDelegate