DTCollectionViewManager
open class DTCollectionViewManager
DTCollectionViewManager
manages most of UICollectionView
datasource and delegate methods and provides API for managing your data models in the collection view. Any method, that is not implemented by DTCollectionViewManager
, will be forwarded to delegate.
See also
startManagingWithDelegate:
-
Bool property, that will be true, after
startManagingWithDelegate
method is called onDTCollectionViewManager
.Declaration
Swift
open var isManagingCollectionView: Bool { get }
-
Implicitly unwrap storage property to
MemoryStorage
.Warning
if storage is not MemoryStorage, will throw an exception.Declaration
Swift
open var memoryStorage: MemoryStorage! { get }
-
Anomaly handler, that handles reported by
DTCollectionViewManager
anomalies.Declaration
Swift
open var anomalyHandler: DTCollectionViewManagerAnomalyHandler
-
Storage, that holds your UICollectionView models. By default, it’s
MemoryStorage
instance.Note
When setting custom storage for this property, it will be automatically configured for using with UICollectionViewFlowLayout and it’s delegate will be set toDTCollectionViewManager
instance.Note
Previous storagedelegate
property will be nilled out to avoid collisions.See also
MemoryStorage
,CoreDataStorage
.Declaration
Swift
open var storage: Storage { get set }
-
Current storage, conditionally casted to
SupplementaryStorage
protocol.Declaration
Swift
public var supplementaryStorage: SupplementaryStorage? { get }
-
Object, that is responsible for updating
UICollectionView
, when received update fromStorage
Declaration
Swift
open var collectionViewUpdater: CollectionViewUpdater? { get set }
-
Object, that is responsible for implementing
UICollectionViewDataSource
protocolDeclaration
Swift
open var collectionDataSource: DTCollectionViewDataSource? { get set }
-
Object, that is responsible for implementing
UICollectionViewDelegate
andUICollectionViewDelegateFlowLayout
protocolsDeclaration
Swift
open var collectionDelegate: DTCollectionViewDelegate? { get set }
-
Object, that is responsible for implementing
UICollectionViewDragDelegate
protocolDeclaration
Swift
open var collectionDragDelegate: DTCollectionViewDragDelegate? { get set }
-
Object, that is responsible for implementing
UICOllectionViewDropDelegate
protocolDeclaration
Swift
open var collectionDropDelegate: DTCollectionViewDropDelegate? { get set }
-
Storage construction block, used by
DTCollectionViewManager
when it’s created. ReturnsMemoryStorage
by default.Declaration
Swift
public static var defaultStorage: () -> Storage
-
Creates
DTCollectionViewManager
. Usually you don’t need to call this method directly, asmanager
property onDTCollectionViewManageable
instance is filled automatically.DTCollectionViewManager.defaultStorage
closure is used to determine whichStorage
would be used by default.Declaration
Swift
public init(storage: Storage = DTCollectionViewManager.defaultStorage())
Parameters
storage
storage class to be used
-
If you access
manager
property when managedUICollectionView
is already created(for example: viewDidLoad method), calling this method is not necessary. If for any reason,UICollectionView
is created later, please call this method before modifying storage or registering cells/supplementary views.Precondition
UICollectionView instance ondelegate
should not be nil.Declaration
Swift
open func startManaging(withDelegate delegate: DTCollectionViewManageable)
Parameters
delegate
Object, that has UICollectionView, that will be managed by
DTCollectionViewManager
. -
Undocumented
Declaration
Swift
open func configureDiffableDataSource<SectionIdentifier, ItemIdentifier>(modelProvider: @escaping (IndexPath, ItemIdentifier) -> Any) -> UICollectionViewDiffableDataSource<SectionIdentifier, ItemIdentifier>
-
Returns closure, that updates cell at provided indexPath.
This is used by
coreDataUpdater
method and can be used to silently update a cell without animation.Declaration
Swift
open func updateCellClosure() -> (IndexPath, Any) -> Void
-
Updates visible cells, using
collectionView.indexPathsForVisibleItems
, and update block. This may be more efficient than runningreloadData
, if number of your data models does not change, and the change you want to reflect is completely within models state.Declaration
Swift
open func updateVisibleCells(_ closure: ((UICollectionViewCell) -> Void)? = nil)
Parameters
closure
closure to run for each cell after update has been completed.
-
Returns
CollectionViewUpdater
, configured to work withCoreDataStorage
andNSFetchedResultsController
updates.Precondition
UICollectionView instance ondelegate
should not be nil.Declaration
Swift
open func coreDataUpdater() -> CollectionViewUpdater
-
Registers
closure
to be executed, whenUICollectionViewDataSource.collectionView(_:canMoveItemAt:)
method is called forcellClass
.Declaration
Swift
open func canMove<Cell>(_ cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Bool) where Cell : UICollectionViewCell
-
Registers
closure
to be executed, whenUICollectionViewDataSrouce.(_:moveItemAt:to:)
method is called forcellClass
.Warning
This method requires items to be moved without animations, since animation has already happened when user moved those cells. If you useMemoryStorage
, it’s appropriate to callmemoryStorage.moveItemWithoutAnimation(from:to:)
method to achieve desired behavior.See also
‘collectionView:moveRowAt:to:’ methodDeclaration
Swift
open func moveItemAtTo(_ closure: @escaping (_ sourceIndexPath: IndexPath, _ destinationIndexPath: IndexPath) -> Void)
-
Undocumented
Declaration
Swift
open func indexTitles(_ closure: @escaping () -> [String]?)
-
Undocumented
Declaration
Swift
open func indexPathForIndexTitle(_ closure: @escaping (String, Int) -> IndexPath)
-
Registers
closure
to be executed, whenUICollectionViewDelegate.collectionView(_:didSelectItemAt:)
method is called forcellClass
.Declaration
Swift
open func didSelect<Cell>(_ cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Void) where Cell : UICollectionViewCell
-
Registers
closure
to be executed, whenUICollectionViewDelegate.collectionView(_:shouldSelectItemAt:)
method is called forcellClass
.Declaration
Swift
open func shouldSelect<Cell>(_ cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Bool) where Cell : UICollectionViewCell
-
Registers
closure
to be executed, whenUICollectionViewDelegate.collectionView(_:shouldDeselectItemAt:)
method is called forcellClass
.Declaration
Swift
open func shouldDeselect<Cell>(_ cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Bool) where Cell : UICollectionViewCell
-
Registers
closure
to be executed, whenUICollectionViewDelegate.collectionView(_:didDeselectItemAt:)
method is called forcellClass
.Declaration
Swift
open func didDeselect<Cell>(_ cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Void) where Cell : UICollectionViewCell
-
Registers
closure
to be executed, whenUICollectionViewDelegate.collectionView(_:shouldHighlightItemAt:)
method is called forcellClass
.Declaration
Swift
open func shouldHighlight<Cell>(_ cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Bool) where Cell : UICollectionViewCell
-
Registers
closure
to be executed, whenUICollectionViewDelegate.collectionView(_:didHighlightItemAt:)
method is called forcellClass
.Declaration
Swift
open func didHighlight<Cell>(_ cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Void) where Cell : UICollectionViewCell
-
Registers
closure
to be executed, whenUICollectionViewDelegate.collectionView(_:didUnhighlightItemAt:)
method is called forcellClass
.Declaration
Swift
open func didUnhighlight<Cell>(_ cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Void) where Cell : UICollectionViewCell
-
Registers
closure
to be executed, whenUICollectionViewDelegate.collectionView(_:willDisplayCell:forItemAt:)
method is called forcellClass
.Declaration
Swift
open func willDisplay<Cell>(_ cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Void) where Cell : UICollectionViewCell
-
Registers
closure
to be executed, whenUICollectionViewDelegate.collectionView(_:willDisplaySupplementaryView:forElementKind:at:)
method is called forsupplementaryClass
ofkind
.Declaration
Swift
open func willDisplaySupplementaryView<View>(_ supplementaryClass: View.Type, forElementKind kind: String, _ closure: @escaping (View, View.ModelType, IndexPath) -> Void) where View : UICollectionReusableView
-
Registers
closure
to be executed, whenUICollectionViewDelegate.collectionView(_:willDisplaySupplementaryView:forElementKind:at:)
method is called forsupplementaryClass
ofUICollectionElementKindSectionHeader
.Declaration
Swift
open func willDisplayHeaderView<View>(_ headerClass: View.Type, _ closure: @escaping (View, View.ModelType, IndexPath) -> Void) where View : UICollectionReusableView
-
Registers
closure
to be executed, whenUICollectionViewDelegate.collectionView(_:willDisplaySupplementaryView:forElementKind:at:)
method is called forsupplementaryClass
ofUICollectionElementKindSectionFooter
.Declaration
Swift
open func willDisplayFooterView<View>(_ footerClass: View.Type, _ closure: @escaping (View, View.ModelType, IndexPath) -> Void) where View : UICollectionReusableView
-
Registers
closure
to be executed, whenUICollectionViewDelegate.collectionView(_:didEndDisplaying:forItemAt:)
method is called forcellClass
.Declaration
Swift
open func didEndDisplaying<Cell>(_ cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Void) where Cell : UICollectionViewCell
-
Registers
closure
to be executed, whenUICollectionViewDelegate.collectionView(_:didEndDisplayingSupplementaryView:forElementKind:at:)
method is called forsupplementaryClass
ofkind
.Declaration
Swift
open func didEndDisplayingSupplementaryView<View>(_ supplementaryClass: View.Type, forElementKind kind: String, _ closure: @escaping (View, View.ModelType, IndexPath) -> Void) where View : UICollectionReusableView
-
Registers
closure
to be executed, whenUICollectionViewDelegate.collectionView(_:didEndDisplayingSupplementaryView:forElementKind:at:)
method is called forheaderClass
ofUICollectionElementKindSectionHeader
.Declaration
Swift
open func didEndDisplayingHeaderView<View>(_ headerClass: View.Type, _ closure: @escaping (View, View.ModelType, IndexPath) -> Void) where View : UICollectionReusableView
-
Registers
closure
to be executed, whenUICollectionViewDelegate.collectionView(_:didEndDisplayingSupplementaryView:forElementKind:at:)
method is called forfooterClass
ofUICollectionElementKindSectionFooter
.Declaration
Swift
open func didEndDisplayingFooterView<View>(_ footerClass: View.Type, _ closure: @escaping (View, View.ModelType, IndexPath) -> Void) where View : UICollectionReusableView
-
Undocumented
Declaration
Swift
open func shouldShowMenu<Cell>(for cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Bool) where Cell : UICollectionViewCell
-
Undocumented
Declaration
Swift
open func canPerformAction<Cell>(for cellClass: Cell.Type, _ closure: @escaping (Selector, Any?, Cell, Cell.ModelType, IndexPath) -> Bool) where Cell : UICollectionViewCell
-
Undocumented
Declaration
Swift
open func performAction<Cell>(for cellClass: Cell.Type, _ closure: @escaping (Selector, Any?, Cell, Cell.ModelType, IndexPath) -> Void) where Cell : UICollectionViewCell
-
Registers
closure
to be executed, whenUICollectionViewDelegate.collectionView(_:canFocusItemAt:)
method is called forcellClass
.Declaration
Swift
open func canFocus<Cell>(_ cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Bool) where Cell : UICollectionViewCell
-
Registers
closure
to be executed whenUICollectionViewDelegate.collectionView(_:shouldUpdateFocusInContext:)
method is called.Declaration
Swift
open func shouldUpdateFocus(_ closure: @escaping (UICollectionViewFocusUpdateContext) -> Bool)
-
Registers
closure
tp be executed whenUICollectionViewDelegate.collectionView(_:didUpdateFocusIn:with:)
method is called.Declaration
Swift
open func didUpdateFocus(_ closure: @escaping (UICollectionViewFocusUpdateContext, UIFocusAnimationCoordinator) -> Void)
-
Registers
closure
to be executed whenUICollectionViewDelegate.indexPathForPreferredFocusedView(in:)
method is calledDeclaration
Swift
open func indexPathForPreferredFocusedView(_ closure: @escaping () -> IndexPath?)
-
Registers
closure
to be executed whenUICollectionViewDelegate.targetIndexPathForMoveFromItemAt(_:toProposed:)
method is called forcellClass
Declaration
Swift
open func targetIndexPathForMovingItem<Cell>(_ cellClass: Cell.Type, _ closure: @escaping (IndexPath, Cell, Cell.ModelType, IndexPath) -> IndexPath) where Cell : UICollectionViewCell
-
Registers
closure
to be executed whenUICollectionViewDelegate.collectionView(_:targetContentOffsetForProposedContentOffset:)
method is called.Declaration
Swift
open func targetContentOffsetForProposedContentOffset(_ closure: @escaping (CGPoint) -> CGPoint)
-
Registers
closure
to be executed whenUICollectionViewDelegate.collectionView(_:shouldSpringLoadItemAt:)
method is called forcellClass
.Declaration
Swift
open func shouldSpringLoad<Cell:ModelTransfer>(_ cellClass: Cell.Type, _ closure: @escaping (UISpringLoadedInteractionContext, Cell, Cell.ModelType, IndexPath) -> Bool) where Cell: UICollectionViewCell
-
Undocumented
Declaration
Swift
open func shouldBeginMultipleSelectionInteraction<Cell:ModelTransfer>(for cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Bool) where Cell: UICollectionViewCell
-
Undocumented
Declaration
Swift
open func didBeginMultipleSelectionInteraction<Cell:ModelTransfer>(for cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Void) where Cell: UICollectionViewCell
-
Undocumented
Declaration
Swift
open func didEndMultipleSelectionInteraction(_ closure: @escaping () -> Void)
-
Undocumented
Declaration
Swift
open func contextMenuConfiguration<Cell:ModelTransfer>(for cellClass: Cell.Type, _ closure: @escaping (CGPoint, Cell, Cell.ModelType, IndexPath) -> UIContextMenuConfiguration?) where Cell: UICollectionViewCell
-
Undocumented
Declaration
Swift
open func previewForHighlightingContextMenu(_ closure: @escaping (UIContextMenuConfiguration) -> UITargetedPreview?)
-
Undocumented
Declaration
Swift
open func previewForDismissingContextMenu(_ closure: @escaping (UIContextMenuConfiguration) -> UITargetedPreview?)
-
Undocumented
Declaration
Swift
open func canEdit<Model>(_ modelType: Model.Type, _ closure: @escaping (Model, IndexPath) -> Bool)
-
Registers
closure
to be executed to determine cell size inUICollectionViewDelegateFlowLayout.collectionView(_:sizeForItemAt:)
method, when it’s called for cell which model is ofitemType
.Declaration
Swift
open func sizeForCell<Model>(withItem: Model.Type, _ closure: @escaping (Model, IndexPath) -> CGSize)
-
Registers
closure
to be executed to determine header size inUICollectionViewDelegateFlowLayout.collectionView(_:layout:referenceSizeForHeaderViewInSection:)
method, when it’s called for header which model is ofitemType
.Declaration
Swift
open func referenceSizeForHeaderView<Model>(withItem: Model.Type, _ closure: @escaping (Model, IndexPath) -> CGSize)
-
Registers
closure
to be executed to determine footer size inUICollectionViewDelegateFlowLayout.collectionView(_:layout:referenceSizeForFooterViewInSection:)
method, when it’s called for footer which model is ofitemType
.Declaration
Swift
open func referenceSizeForFooterView<Model>(withItem: Model.Type, _ closure: @escaping (Model, IndexPath) -> CGSize)
-
Registers
closure
to be executed whenUICollectionViewDelegate.collectionView(_:transitionLayoutForOldLayout:toNewLayout:
) method is calledDeclaration
Swift
open func transitionLayout(_ closure: @escaping (_ oldLayout: UICollectionViewLayout, _ newLayout: UICollectionViewLayout) -> UICollectionViewTransitionLayout)
-
Registers
closure
to be executed whenUICollectionViewDelegateFlowLayout.collectionView(_:layout:insetForSectionAt:)
method is called.Declaration
Swift
open func insetForSectionAtIndex(_ closure: @escaping (UICollectionViewLayout, Int) -> UIEdgeInsets)
-
Registers
closure
to be executed whenUICollectionViewDelegateFlowLayout.collectionView(_:layout:minimumLineSpacingForSectionAt:)
method is called.Declaration
Swift
open func minimumLineSpacingForSectionAtIndex(_ closure: @escaping (UICollectionViewLayout, Int) -> CGFloat)
-
Registers
closure
to be executed whenUICollectionViewDelegateFlowLayout.collectionView(_:layout:insetForSectionAt:)
method is called.Declaration
Swift
open func minimumInteritemSpacingForSectionAtIndex(_ closure: @escaping (UICollectionViewLayout, Int) -> CGFloat)
-
Undocumented
Declaration
Swift
func configureEvents<T>(for klass: T.Type, _ closure: (T.Type, T.ModelType.Type) -> Void)
-
Undocumented
Declaration
Swift
func configure<T>(_ cellClass: T.Type, _ closure: @escaping (T, T.ModelType, IndexPath) -> Void) where T : UICollectionViewCell
-
Undocumented
Declaration
Swift
func configureHeader<T>(_ headerClass: T.Type, _ closure: @escaping (T, T.ModelType, Int) -> Void) where T : UICollectionReusableView
-
Undocumented
Declaration
Swift
func configureFooter<T>(_ footerClass: T.Type, _ closure: @escaping (T, T.ModelType, Int) -> Void) where T : UICollectionReusableView
-
Undocumented
Declaration
Swift
func configureSupplementary<T>(_ supplementaryClass: T.Type, ofKind kind: String, _ closure: @escaping (T, T.ModelType, IndexPath) -> Void) where T : UICollectionReusableView
-
Undocumented
Declaration
Swift
func registerNiblessSupplementary<T>(_ supplementaryClass: T.Type, forKind kind: String, mappingBlock: ((ViewModelMapping<T, T.ModelType>) -> Void)? = nil) where T : UICollectionReusableView
-
Undocumented
Declaration
Swift
func registerNiblessHeader<T>(_ headerClass: T.Type, mappingBlock: ((ViewModelMapping<T, T.ModelType>) -> Void)? = nil) where T : UICollectionReusableView
-
Undocumented
Declaration
Swift
func registerNiblessFooter<T>(_ footerClass: T.Type, mappingBlock: ((ViewModelMapping<T, T.ModelType>) -> Void)? = nil) where T : UICollectionReusableView
-
Undocumented
Declaration
Swift
func registerNibless<T>(_ cellClass: T.Type, mappingBlock: ((ViewModelMapping<T, T.ModelType>) -> Void)? = nil) where T : UICollectionViewCell
-
Undocumented
Declaration
Swift
func registerNibNamed<T>(_ nibName: String, forSupplementary supplementaryClass: T.Type, ofKind kind: String, mappingBlock: ((ViewModelMapping<T, T.ModelType>) -> Void)? = nil) where T : UICollectionReusableView
-
Undocumented
Declaration
Swift
func registerNibNamed<T>(_ nibName: String, forHeader headerClass: T.Type, mappingBlock: ((ViewModelMapping<T, T.ModelType>) -> Void)? = nil) where T : UICollectionReusableView
-
Undocumented
Declaration
Swift
func registerNibNamed<T>(_ nibName: String, forFooter footerClass: T.Type, mappingBlock: ((ViewModelMapping<T, T.ModelType>) -> Void)? = nil) where T : UICollectionReusableView
-
Undocumented
Declaration
Swift
func registerNibNamed<T>(_ nibName: String, for cellClass: T.Type, mappingBlock: ((ViewModelMapping<T, T.ModelType>) -> Void)? = nil) where T : UICollectionViewCell
-
Registers
closure
to be executed whenUICollectionViewDragDelegate.collectionView(_:itemsForBeginning:at:)
method is called forcellClass
.Declaration
Swift
open func itemsForBeginningDragSession<Cell>(from cellClass: Cell.Type, _ closure: @escaping (UIDragSession, Cell, Cell.ModelType, IndexPath) -> [UIDragItem]) where Cell : UICollectionViewCell
-
Registers
closure
to be executed whenUICollectionViewDragDelegate.collectionView(_:itemsForAddingTo:at:point:)
method is called forcellClass
Declaration
Swift
open func itemsForAddingToDragSession<Cell>(from cellClass: Cell.Type, _ closure: @escaping (UIDragSession, CGPoint, Cell, Cell.ModelType, IndexPath) -> [UIDragItem]) where Cell : UICollectionViewCell
-
Registers
closure
to be executed whenUICollectionViewDragDelegate.collectionView(_:dragPreviewParametersForRowAt:)
method is called forcellClass
Declaration
Swift
open func dragPreviewParameters<Cell>(for cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> UIDragPreviewParameters?) where Cell : UICollectionViewCell
-
Registers
closure
to be executed whenUICollectionViewDragDelegate.collectionView(_:dragSessionWillBegin:)
method is called.Declaration
Swift
open func dragSessionWillBegin(_ closure: @escaping (UIDragSession) -> Void)
-
Registers
closure
to be executed whenUICollectionViewDragDelegate.collectionView(_:dragSessionDidEnd:)
method is called.Declaration
Swift
open func dragSessionDidEnd(_ closure: @escaping (UIDragSession) -> Void)
-
Registers
closure
to be executed whenUICollectionViewDragDelegate.collectionView(_:dragSessionAllowsMoveOperation)
method is called.Declaration
Swift
open func dragSessionAllowsMoveOperation(_ closure: @escaping (UIDragSession) -> Bool)
-
Registers
closure
to be executed whenUICollectionViewDragDelegate.collectionView(_:dragSessionIsRestrictedToDraggingApplication:)
method is called.Declaration
Swift
open func dragSessionIsRestrictedToDraggingApplication(_ closure: @escaping (UIDragSession) -> Bool)
-
Registers
closure
to be executed whenUICollectionViewDropDelegate.collectionView(_:performDropWith:)
method is called.Declaration
Swift
open func performDropWithCoordinator(_ closure: @escaping (UICollectionViewDropCoordinator) -> Void)
-
Registers
closure
to be executed whenUICollectionViewDropDelegate.collectionView(_:canHandle:)
method is called.Declaration
Swift
open func canHandleDropSession(_ closure: @escaping (UIDropSession) -> Bool)
-
Registers
closure
to be executed whenUICollectionViewDropDelegate.collectionView(_:dropSessionDidEnter:)
method is called.Declaration
Swift
open func dropSessionDidEnter(_ closure: @escaping (UIDropSession) -> Void)
-
Registers
closure
to be executed whenUICollectionViewDropDelegate.collectionView(_:dropSessionDidUpdate:withDestination:)
method is called.Declaration
Swift
open func dropSessionDidUpdate(_ closure: @escaping (UIDropSession, IndexPath?) -> UICollectionViewDropProposal)
-
Registers
closure
to be executed whenUICollectionViewDropDelegate.collectionView(_:dropSessionDidExit:)
method is called.Declaration
Swift
open func dropSessionDidExit(_ closure: @escaping (UIDropSession) -> Void)
-
Registers
closure
to be executed whenUICollectionViewDropDelegate.collectionView(_:dropSessionDidEnd:)
method is called.Declaration
Swift
open func dropSessionDidEnd(_ closure: @escaping (UIDropSession) -> Void)
-
Registers
closure
to be executed whenUICollectionViewDropDelegate.collectionView(_:dropPreviewParametersForRowAt:)
method is called.Declaration
Swift
open func dropPreviewParameters(_ closure: @escaping (IndexPath) -> UIDragPreviewParameters?)
-
Convenience method for dropping
item
intoplaceholder
. ReturnsDTCollectionViewDropPlaceholderContext
, which is a replacement forUICollectionViewDropPlaceholderContext
, that automatically handles drop if you are usingMemoryStorage
. It also automatically dispatches insertion toDispatchQueue.main
.Declaration
Swift
open func drop(_ item: UIDragItem, to placeholder: UICollectionViewDropPlaceholder, with coordinator: UICollectionViewDropCoordinator) -> DTCollectionViewDropPlaceholderContext
-
Registers mapping for
cellClass
. Mapping will automatically check for nib with the same name ascellClass
and register it, if it is found. If cell is designed in storyboard, please setmapping.cellRegisteredByStoryboard
property totrue
inside ofmapping
closure.Note
handler
closure is called beforeupdate(with:)
method.Declaration
Swift
open func register<T:ModelTransfer>(_ cellClass:T.Type, mapping: ((ViewModelMapping<T, T.ModelType>) -> Void)? = nil, handler: @escaping (T, T.ModelType, IndexPath) -> Void = { _, _, _ in }) where T: UICollectionViewCell
Parameters
cellClass
UICollectionViewCell subclass type, conforming to
ModelTransfer
protocol.mapping
mapping configuration closure, executed before any registration or dequeue is performed.
handler
configuration closure, that is run when cell is dequeued.
-
Registers mapping from
modelType
tocellClass
. Mapping will automatically check for nib with the same name ascellClass
and register it, if it is found. If cell is designed in storyboard, please setmapping.cellRegisteredByStoryboard
property totrue
inside ofmapping
closure.Declaration
Swift
open func register<Cell, Model>(_ cellClass: Cell.Type, for modelType: Model.Type, mapping: ((ViewModelMapping<Cell, Model>) -> Void)? = nil, handler: @escaping (Cell, Model, IndexPath) -> Void) where Cell : UICollectionViewCell
Parameters
cellClass
UICollectionViewCell to register
modelType
Model type, which is mapped to
cellClass
.mapping
mapping configuration closure, executed before any registration or dequeue is performed.
handler
configuration closure, that is run when cell is dequeued.
-
Registers mapping for
headerClass
.UICollectionView.elementKindSectionHeader
is used as a supplementary kind. Mapping will automatically check for nib with the same name asheaderClass
and register it, if it is found. If supplementary view is designed in storyboard, please setmapping.supplementaryRegisteredByStoryboard
property totrue
inside ofmapping
closure.Note
handler
closure is called beforeupdate(with:)
method.Declaration
Swift
open func registerHeader<View:ModelTransfer>(_ headerClass : View.Type, mapping: ((ViewModelMapping<View, View.ModelType>) -> Void)? = nil, handler: @escaping (View, View.ModelType, IndexPath) -> Void = { _, _, _ in }) where View: UICollectionReusableView
Parameters
headerClass
UICollectionReusableView class to register
modelType
Model type, which is mapped to
headerClass
.mapping
mapping configuration closure, executed before any registration or dequeue is performed.
handler
configuration closure, that is run when supplementary view is dequeued.
-
Registers mapping from
modelType
toheaderClass
.UICollectionView.elementKindSectionHeader
is used as a supplementary kind. Mapping will automatically check for nib with the same name asheaderClass
and register it, if it is found. If header is designed in storyboard, please setmapping.supplementaryRegisteredByStoryboard
property totrue
inside ofmapping
closure.Declaration
Swift
open func registerHeader<View:UICollectionReusableView, Model>(_ headerClass: View.Type, for modelType: Model.Type, mapping: ((ViewModelMapping<View, Model>) -> Void)? = nil, handler: @escaping (View, Model, IndexPath) -> Void = { _, _, _ in })
Parameters
headerClass
UICollectionReusableView class to register
modelType
Model type, which is mapped to
headerClass
.mapping
mapping configuration closure, executed before any registration or dequeue is performed.
handler
configuration closure, that is run when header is dequeued.
-
Registers mapping for
footerClass
.UICollectionView.elementKindSectionFooter
is used as a supplementary kind. Mapping will automatically check for nib with the same name asfooterClass
and register it, if it is found. If supplementary view is designed in storyboard, please setmapping.supplementaryRegisteredByStoryboard
property totrue
inside ofmapping
closure.Note
handler
closure is called beforeupdate(with:)
method.Declaration
Swift
open func registerFooter<View:ModelTransfer>(_ footerClass: View.Type, mapping: ((ViewModelMapping<View, View.ModelType>) -> Void)? = nil, handler: @escaping (View, View.ModelType, IndexPath) -> Void = { _, _, _ in }) where View:UICollectionReusableView
Parameters
footerClass
UICollectionReusableView class to register
modelType
Model type, which is mapped to
footerClass
.mapping
mapping configuration closure, executed before any registration or dequeue is performed.
handler
configuration closure, that is run when supplementary view is dequeued.
-
Registers mapping from
modelType
tofooterClass
.UICollectionView.elementKindSectionFooter
is used as a supplementary kind. Mapping will automatically check for nib with the same name asfooterClass
and register it, if it is found. If footer is designed in storyboard, please setmapping.supplementaryRegisteredByStoryboard
property totrue
inside ofmapping
closure.Declaration
Swift
open func registerFooter<View:UICollectionReusableView, Model>(_ footerClass: View.Type, for modelType: Model.Type, mapping: ((ViewModelMapping<View, Model>) -> Void)? = nil, handler: @escaping (View, Model, IndexPath) -> Void = { _, _, _ in })
Parameters
footerClass
UICollectionReusableView class to register
modelType
Model type, which is mapped to
footerClass
.mapping
mapping configuration closure, executed before any registration or dequeue is performed.
handler
configuration closure, that is run when footer is dequeued.
-
Registers mapping for
footerClass
. Mapping will automatically check for nib with the same name assupplementaryClass
and register it, if it is found. If supplementary view is designed in storyboard, please setmapping.supplementaryRegisteredByStoryboard
property totrue
inside ofmapping
closure.Note
handler
closure is called beforeupdate(with:)
method.Declaration
Swift
open func registerSupplementary<View:ModelTransfer>(_ supplementaryClass: View.Type, ofKind kind: String, mapping: ((ViewModelMapping<View, View.ModelType>) -> Void)? = nil, handler: @escaping (View, View.ModelType, IndexPath) -> Void = { _, _, _ in }) where View:UICollectionReusableView
Parameters
supplementaryClass
UICollectionReusableView class to register
kind
supplementary view kind
mapping
mapping configuration closure, executed before any registration or dequeue is performed.
handler
configuration closure, that is run when supplementary view is dequeued.
-
Registers mapping from
modelType
tosupplementaryClass
. Mapping will automatically check for nib with the same name assupplementaryClass
and register it, if it is found. If supplementary view is designed in storyboard, please setmapping.supplementaryRegisteredByStoryboard
property totrue
inside ofmapping
closure.Declaration
Swift
open func registerSupplementary<View:UICollectionReusableView, Model>(_ supplementaryClass: View.Type, for modelType: Model.Type, ofKind kind: String, mapping: ((ViewModelMapping<View, Model>) -> Void)? = nil, handler: @escaping (View, Model, IndexPath) -> Void = { _, _, _ in })
Parameters
footerClass
UICollectionReusableView class to register
modelType
Model type, which is mapped to
supplementaryClass
.mapping
mapping configuration closure, executed before any registration or dequeue is performed.
handler
configuration closure, that is run when supplementary view is dequeued.
-
Unregisters
cellClass
fromDTCollectionViewManager
andUICollectionView
.Declaration
Swift
open func unregister<Cell>(_ cellClass: Cell.Type) where Cell : UICollectionViewCell
-
Unregisters
headerClass
fromDTCollectionViewManager
andUICollectionView
.Declaration
Swift
open func unregisterHeader<View>(_ headerClass: View.Type) where View : UICollectionReusableView
-
Unregisters
footerClass
fromDTCollectionViewManager
andUICollectionView
.Declaration
Swift
open func unregisterFooter<View>(_ headerClass: View.Type) where View : UICollectionReusableView
-
Unregisters
supplementaryClass
ofkind
fromDTCollectionViewManager
andUICollectionView
.Declaration
Swift
open func unregisterSupplementary<View>(_ supplementaryClass: View.Type, ofKind kind: String) where View : UICollectionReusableView