Protocol-oriented UICollectionView management, powered by generics and associated types.

Overview

CI codecov.io CocoaPod platform CocoaPod version Swift Package Manager compatible Packagist

DTCollectionViewManager

Features

  • Powerful mapping system between data models and cells, headers and footers
  • Automatic datasource and interface synchronization.
  • Flexible Memory/CoreData/Realm/diffable datasource storage options
  • Powerful compile-time safe events system, that covers all of UICollectionView delegate methods
  • Views created from code, XIB, or storyboard, automatic registration and dequeue
  • Can be used with UICollectionViewController, or UIViewController with UICollectionView
  • Built-in support for iOS 14 UICollectionView.CellRegistration and content configuration
  • Unified syntax with DTTableViewManager
  • Complete documentation
  • API Reference

Requirements

  • Xcode 12+
  • iOS 11.0+ / tvOS 11.0+ / macCatalyst 13.0+
  • Swift 5.3+

If you need Xcode 11 support or Swift 4...Swift 5.2, or iOS 8...iOS 10 support, you can use 7.x releases.

Installation

Swift Package Manager

Add package into Xcode Project settings -> Swift Packages

CocoaPods:

pod 'DTCollectionViewManager', '~> 10.0.0'

Quick start

Let's say you have an array of Posts you want to display in UICollectionView. To quickly show them using DTCollectionViewManager, here's what you need to do:

  1. Create UICollectionViewCell subclass, let's say PostCell and adopt ModelTransfer protocol:
class PostCell : UICollectionViewCell, ModelTransfer {
    func update(with model: Post) {
        // Fill your cell with actual data
    }
}
  1. In your view controller:
class PostsViewController: UICollectionViewController, DTCollectionViewManageable {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Register PostCell to be used with this controller's collection view
        manager.register(PostCell.self)

        // Populate datasource
        manager.memoryStorage.setItems(posts)
    }
}    

Make sure your UICollectionView outlet is wired to your class (or use UICollectionViewController subclass). If you have a PostCell.xib file, it will be automatically used for dequeueing PostCell.

  1. That's it! It's that easy!

Of course, cool stuff does not stop there, framework supports all datasource and delegate methods as closures, conditional mappings and much much more! Choose what interests you in the next section of readme.

Burning questions

Starter pack
Advanced

Sample code and documentation

Thanks

  • Alexey Belkevich for providing initial implementation of CellFactory.
  • Michael Fey for providing insight into NSFetchedResultsController updates done right.
  • Nickolay Sheika for great feedback, that helped shaping 3.0 release and future direction of the library.
  • Artem Antihevich for great discussions about Swift generics and type capturing.
Comments
  • can you set more than one `configure` block for a cell class?

    can you set more than one `configure` block for a cell class?

    I was trying to do something where I was calling configure twice on the same cell class.

    Looking at the configure code, it calls a routine named appendReaction, which made me think that I could do this. Ordering of the two blocks doesn't matter. But I noticed, while stepping through, that delegateWasReset gets called when the reaction is appended. The end result is that the second configure block is not called.

    Anyway, just wondering if 2 configure blocks can be added to the same cell-class, and if so, how? If not, then I just need to know that.

    wontfix 
    opened by skydivedan 5
  • performBatchUpdates bug

    performBatchUpdates bug

    Random crashes may happen because this issue: https://openradar.appspot.com/28167779

    I use DTCollectionViewManager with Realm, it threw this error:

    Fatal Exception: RLMException
    Index 6 is out of bounds (must be less than 0)
    
    question waiting for feedback 
    opened by scottphc 5
  • Items get messed up when sections are added

    Items get messed up when sections are added

    Scrolling and reusing items seems to work fine when there are no sections present, but as soon as I add one, the list get laggy and jumpy. Also, the second section somehow overlaps some of the items.

    The code (in a view, inside awakeFromNib):

    manager.registerHeader(TimeHeader.self) { $0.condition = .section(0) } manager.registerHeader(TimeSectionHeader.self) { $0.condition = .section(1) } storage.setSectionHeaderModel(TimeHeaderModel(), forSection: 0) storage.setSectionHeaderModel(TimeSectionHeaderModel(timeDay: .monday), forSection: 1)

    Then I'm simply adding models to storage as usual.

    question 
    opened by rablador 4
  • Function storageDidPerformUpdate Batch update error

    Function storageDidPerformUpdate Batch update error

    Got this little ditty from the compiler as it threw an runtime exception

    Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (10) must be equal to the number of items contained in that section before the update (10), plus or minus the number of items inserted or deleted from that section (10 inserted, 0 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out).

    Now i recall a year or so back running into the same problem when working with UICollectionViews and i did come up with a solution but it escapes me, luckily i believe someone else documented their struggles and solutions on the same problem.

    any change of an update or would you like me to make a pull request? I wont be able to do so myself for a few days at least...Work deadlines and such.

    enhancement 
    opened by Genhain 4
  • registerCellClass with no nibs

    registerCellClass with no nibs

    Currently I'm not using nibs nor storyboard, thus I just call registerCellClass:. When the CollectionView tries to dequeue a cell it raises an exception saying that no cell class has been registered. The fix is easy, I just need to call collectionView?.registerClass(CellClass.self, forCellWithReuseIdentifier: "<reuse identifier that would be generated with reflection>") from my view controller. This kind of stuff could go in the library itself, in my opinion. Also because if one day you change identifier, my code breaks.

    What do you think? Before I open a PR, I'd like to know if it would be enough to add the code above to an else clause in the registerCellClass: method or if there's no else clause because that's needed for storyboards compatibility: if no nib exists it means that the view is in the storyboard?

    If that's the case, I propose to handle the pure (code only) case in the method registerCellClass: and add a new method registerCellClassWithNoStoryboardNorNib: that has the current implementation (suggestions for method names are appreciated!!).

    (I'll obviously update the cousin registerSupplementaryClass: forKind: method)

    enhancement 
    opened by vendruscolo 4
  • Crash when inserting items

    Crash when inserting items

    CollectionViewManager crashes when it checks if it shouldReloadCollectionViewToPreventInsertFirstItemIssueForUpdate

    In particular, I'm asynchronously adding new items to the manager:

    private func contentLoaded(resources: [Container]?, error: ErrorType?) {
        print("content loaded")
    
        if resources != nil {
            manager.memoryStorage.addItems(resources!)
        }
    }
    

    The manager then checks:

    for indexPath in update.insertedRowIndexPaths {
        if self.collectionView.numberOfItemsInSection(indexPath.section) == 0 {
            shouldReload = true
            break
        }
    }
    

    And crashes when calls self.collectionView.numberOfItemsInSection(indexPath.section) (in that moment, there were 0 sections with 0 items). Removing those lines make the app work correctly.

    I run the app on the iOS 9 Simulator.

    Exception logged:

    *** Assertion failure in -[UICollectionViewData numberOfItemsInSection:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3505.16/UICollectionViewData.m:566
    2015-10-02 17:48:42.212 Sales App[82499:1913317] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'request for number of items in section 0 when there are only 0 sections in the collection view'
    
    bug enhancement 
    opened by vendruscolo 4
  • collectionview optional?

    collectionview optional?

    Hello! Why is collection view in DTCollectionViewManageable optional? It will be better if it is nonoptional value like in DTTableViewManageable

    public protocol DTTableViewManageable : class
    {
        /// Table view, that will be managed by DTTableViewManager
        var tableView : UITableView! { get }
    }
    
    public protocol DTCollectionViewManageable : class
    {
        /// Collection view, that will be managed by DTCollectionViewManager
        var collectionView : UICollectionView? { get }
    }
    
    enhancement 
    opened by onsissond 3
  • Clearer documentation examples

    Clearer documentation examples

    Took me a bit to time to get the order of setup & that I need to perform fetch on my NSFetchedResultsController

    Here's my code:

        override func viewDidLoad() {
            super.viewDidLoad()
    
            let fetchRequest = NSFetchRequest(entityName: "Photograph")
            //fetchRequest.predicate = self.predicate
            fetchRequest.sortDescriptors = [NSSortDescriptor(key: "primaryKey", ascending: true)]
    
            let ctx = RKObjectManager.sharedManager().managedObjectStore.persistentStoreManagedObjectContext
            let frc = NSFetchedResultsController(fetchRequest: fetchRequest,
                                                 managedObjectContext: ctx,
                                                 sectionNameKeyPath: nil,
                                                 cacheName: nil)
    
            do {
                try frc.performFetch()
            } catch {
                let fetchError = error as NSError
                print("\(fetchError), \(fetchError.userInfo)")
            }
    
            self.manager.storage = CoreDataStorage(fetchedResultsController: frc)
            self.manager.startManagingWithDelegate(self)
            self.manager.registerNiblessCellClass(GalleryImageCell)
        }
    
    opened by markst 3
  • Crash with nil header

    Crash with nil header

    In your method:

    - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView
               viewForSupplementaryElementOfKind:(NSString *)kind
                                     atIndexPath:(NSIndexPath *)indexPath
    {
        UICollectionReusableView <DTModelTransfer> *view = nil;
        id supplementary = nil;
        if ([self.storage respondsToSelector:@selector(supplementaryModelOfKind:forSectionIndex:)])
        {
            supplementary = [self.storage supplementaryModelOfKind:kind forSectionIndex:indexPath.section];
        }
    
        if (supplementary)
        {
            view = [self.factory supplementaryViewOfKind:kind
                                                 forItem:supplementary
                                             atIndexPath:indexPath];
            [view updateWithModel:supplementary];
        }
    
        return view;
    }
    

    If no reusable view was registered, you will return nil. Since IOS7 it's create a crash.

    opened by oks 3
  • Calling `UICollectionViewCell.canBecomeFocused` from within `DTCollectionViewDelegate.canFocusItemAt` can create an infinite recursion.

    Calling `UICollectionViewCell.canBecomeFocused` from within `DTCollectionViewDelegate.canFocusItemAt` can create an infinite recursion.

    Saw an issue where the delegate routine for canFocus could be called recursively, until a crash. Issue was mis-filed over in the DTTableViewManager project (sorry!). https://github.com/DenHeadless/DTTableViewManager/issues/64

    When calling the cell's canBecomeFocused routine, it may call the delegate's canFocusItemAt routuine (the routine where this change is). To avoid this, we're removing the call to canBecomeFocused here.

    opened by skydivedan 2
  • Specifying Different Supplementary Views Per Section

    Specifying Different Supplementary Views Per Section

    How can I specify that I want a certain supplementary view to show up in a certain section of the collectionView?

    Maybe i am missing where in the docs I can do this

    e.x Section 1 = HeaderViewOne Section 2 = HeaderViewTwo . . . Section n = HeaderViewN

    question 
    opened by RyanCodes 2
Releases(11.0.0)
  • 11.0.0(Oct 6, 2022)

    Added

    • Support for UICollectionViewDelegate.collectionView(_:canPerformPrimaryActionForItemAt:) and UICollectionViewDelegate.collectionView(_:performPrimaryActionForItemAt:) delegate methods on iOS 16 and tvOS 16.
    • Support for UICollectionViewDelegate.collectionView(_:contextMenuConfigurationForItemsAt:point:), UICollectionViewDelegate.collectionView(_:contextMenuConfiguration:highlightPreviewForItemAt:) and UICollectionViewDelegate.collectionView(_:contextMenuConfiguration:dismissalPreviewForItemAt: methods on iOS 16.
    • Support for UIHostingConfiguration on iOS 16 / tvOS 16 / macCatalyst 16:
    manager.registerHostingConfiguration(for: Post.self) { _, post, _ in
        UIHostingConfiguration {
            PostView(post: post)
        }
    }
    

    It's also possible to incorporate UIKit cell states by simply adding additional parameter to registration:

    manager.registerHostingConfiguration(for: Post.self) { state, _, post, _ in
        UIHostingConfiguration {
            PostView(post: post, isSelected: state.isSelected)
        }
    }
    

    Additionally, it's possible to customize UICollectionViewCell being used to host SwiftUI view, for example for list cells:

    manager.registerHostingConfiguration(for: Post.self, cell: UICollectionViewListCell.self) { _, post, _ in
        UIHostingConfiguration {
            PostView(post: post)
        }
    }
    
    • Support for events, wrapping UICollectionViewDataSourcePrefetching protocol.
    manager.register(PostCell.self) { mapping in
        mapping.prefetch { model, indexPath in }
        mapping.cancelPrefetch { model, indexPath in }
    }
    

    Please note, that while datasource methods are called once per array of indexPaths, events for models will be called individually, so single model (and indexPath) is passed to each event. Theoretically, this should make prefetching and cancellation easier, since you no longer need to walk through array and find all data models, you can operate on a single data model at a time.

    Deprecated

    • Cell / View events, registered with DTCollectionViewManager are soft-deprecated. Please use events in mapping instead:

    Deprecated:

        manager.register(PostCell.self)
        manager.didSelect(PostCell.self) { postCell, post, indexPath in }
    

    Recommended:

        manager.register(PostCell.self) { mapping in
            mapping.didSelect { postCell, post, indexPath in }
        }
    

    While previously main benefits for second syntax were mostly syntactic, now with support for SwiftUI it will be hard to actually specialize hosting cells (and might be impossible when iOS 16 hosting configuration is supported), so only second syntax will work for all kinds of cells, and first syntax can only work for non-SwiftUI cells. New delegate methods for UICollectionView (starting with iOS 16 / tvO 16 SDK) will be added only as extension to mapping protocols, not DTCollectionViewManager itself.

    Source code(tar.gz)
    Source code(zip)
  • 11.0.0-beta.1(Jul 11, 2022)

    Introducing support for SwiftUI!

    Registering SwiftUI views as content for collection view cells:

    manager.registerHostingCell(for: Post.self) { model, indexPath in
        PostSwiftUIView(model: model)
    }
    

    This method is supported on iOS 13+ / tvOS 13+ / macCatalyst 13+.

    Please note, that this integration is not supported by Apple, therefore it comes with several workarounds, read more about those in SwiftUI support document

    Added

    • HostingCellViewModelMapping - CellViewModelMapping subclass to register mappings fro SwiftUI views.
    • HostingCollectionViewCell - UICollectionViewCell subclass , implementing container for SwiftUI view embedded into it.
    • HostingCollectionViewCellConfiguration - configuration for SwiftUI views hosting inside HostingCollectionViewCell.

    Changed

    • Event reactions are now defined in protocol extension instead of extending former ViewModelMapping protocol, thus allowing to call those methods not only for UIKit mappings, but SwiftUI-hosted cells as well.

    Breaking

    • ViewModelMapping class and it's protocol have been split into multiple classes and protocols for better subclassability (for example CellViewModelMapping / CollectionViewCellModelMapping). Please note, that while technically this is breaking, it's very unlikely to break anything in code, since this type is only present in mapping closures, and public interfaces did not change at all.
    Source code(tar.gz)
    Source code(zip)
  • 10.0.0(Dec 2, 2021)

    Added

    • Wrappers for collectionView:selectionFollowsFocusForItemAtIndexPath: delegate method.
    • Wrappers for iOS 15 UICollectionViewDelegate.collectionView(_:targetIndexPathForMoveOfItemFromOriginalIndexPath:atCurrentIndexPath:toProposedIndexPath:) delegate method.

    Removed

    • Wrappers for collectionView:willCommitMenuWithAnimator delegate method, that was only briefly available in Xcode 12, and was removed by Apple in one of Xcode 12 releases.

    Changed

    • To align version numbers between DTModelStorage, DTTableViewManager and DTCollectionViewManager, DTCollectionViewManager will not have 9.x release, instead it's being released as 10.x.

    Deprecated

    • targetIndexPathForMovingItem deprecated on iOS / tvOS 15 and higher, because delegate method collectionView:targetIndexPathForMoveFromItemAt:toProposedIndexPath: was deprecated in favor of newer method.
    Source code(tar.gz)
    Source code(zip)
  • 9.0.0-beta.1(Jul 12, 2021)

  • 7.1.3(May 14, 2021)

  • 7.1.2(May 14, 2021)

  • 7.1.1(May 14, 2021)

    Note: This is backwards-compatibility release, it only fixes build issue with Xcode 12.5. For future development please consider migrating to DTCollectionViewManager 8.

    Fixed

    • Build issues with Xcode 12.5
    Source code(tar.gz)
    Source code(zip)
  • 8.2.0(Apr 27, 2021)

    Changed

    • UICollectionViewDatasource.indexTitles(for:) and UICollectionViewDatasource.collectionView(_: indexPathForIndexTitle:at:) methods and events now require iOS 14 (and seem to be working only on iOS 14) as per SDK changes in Xcode 12.5.

    Fixed

    • Xcode 12.5 / Swift 5.4 warnings
    • Cell and supplementary view anomaly verification now correctly checks if corresponding subclasses respond to init(frame:) initializer.
    Source code(tar.gz)
    Source code(zip)
  • 8.1.0(Mar 3, 2021)

    This release fixes a critical issue with cell and supplementary reuse on iOS 14 / tvOS 14. If you are using 8.x release, it's highly recommended to upgrade to this release.

    Changed

    • UICollectionView.CellRegistration and UICollectionView.SupplementaryRegistration on iOS 14 / tvOS 14 are now created once per mapping, thus properly allowing cell and supplementary reuse.

    Deprecated

    • DTCollectionViewManagerAnomaly.differentCellReuseIdentifier. If you are using cells from code or from xib, please use empty reuseIdentifier, because on iOS 14 / tvOS 14 reuseIdentifiers are being set by UICollectionView.CellRegistration object. If you are using storyboards, set reuseIdentifier of the cell to cell subclass name.
    Source code(tar.gz)
    Source code(zip)
  • 8.0.1(Dec 16, 2020)

  • 8.0.0(Oct 27, 2020)

    Added

    • Registering events for UICollectionViewDelegateFlowLayout protocol now triggers an anomaly, if different layout class is used (for example UICollectionViewCompositionalLayout)
    Source code(tar.gz)
    Source code(zip)
  • 8.0.0-beta.1(Sep 2, 2020)

    This is a major release with some breaking changes, please read DTCollectionViewManager 8.0 Migration Guide

    New

    • Cell and supplementary view events are now available inside mapping closure directly, for example:
    // Previous releases
    manager.register(PostCell.self)
    manager.didSelect(PostCell.self) { cell, model, indexPath in
        // React to selection
    }
    
    // New
    manager.register(PostCell.self) { mapping in
        mapping.didSelect { cell, model, indexPath in
    
        }
    }
    

    Those events are now tied to ViewModelMapping instance, which means, that events, registered this way, will only trigger, if mapping condition of current mapping applies. For example:

    manager.register(PostCell.self) { mapping in
        mapping.condition = .section(0)
        mapping.didSelect { cell, model, indexPath in  
            // This closure will only get called, when user selects cell in the first section
        }
    }
    manager.register(PostCell.self) { mapping in
        mapping.condition = .section(1)
        mapping.didSelect { cell, model, indexPath in  
            // This closure will only get called, when user selects cell in the second section
        }
    }
    
    • It's now possible to register collection view cells, that don't conform to DTModelTransfer protocol:
    manager.register(UICollectionViewCell.self, String.self) { cell, indexPath, model in
        // configure cell with model which is of type String when passed into configuration closure.
    }
    

    This is particularly useful on iOS / tvOS 14 and higher, where you can configure UICollectionViewListCell without needing to subclass it. Cells, registered in this way, can safely coexist with cells, that conform to DTModelTransfer protocol. Conditional mappings are also supported (multiple trailing closures syntax available in Swift 5.3):

    manager.register(UICollectionViewCell.self, for: String.self) {
        $0.condition = .section(0)
    } handler { cell, indexPath, model in
      // configure cell with model which is of type String when passed into configuration closure.
    }
    
    • Added event reaction for UICollectionViewDelegate.collectionView(_:canEditItemAt:) delegate method.
    • Added event reactions for tvOS 13 TVCollectionViewDelegateFullScreenLayout protocol from TVUIKit framework.
    • New readme and in-depth documentation, split into several sections for developer convenience.

    Changed

    • On iOS/tvOS 14 and higher, cell and supplementary views now use UICollectionView.dequeueConfiguredReusableCell and UICollectionView.dequeueConfiguredReusableSupplementary to be dequeued.
    • DTModelTransfer update(with:) method for such cells and supplementary views is called immediately after dequeueConfiguredReusableCell \ dequeueConfiguredReusableSupplementary return.
    • Generic placeholders for cell/model/view methods have been improved for better readability.

    Breaking

    This release requires Swift 5.3. Minimum iOS / tvOS deployment targets are unchanged (iOS 11, tvOS 11).

    Some context: this release heavily relies on where clauses on contextually generic declarations, that are only available in Swift 5.3 - SE-0267.

    • Cells, headers and footers created in storyboard now need to be explicitly configured in view mapping:
    register(StoryboardCell.self) { mapping in
        mapping.cellRegisteredByStoryboard = true
    }
    
    registerHeader(StoryboardHeader.self) { mapping in
        mapping.supplementaryRegisteredByStoryboard = true
    }
    
    • All non-deprecated registration methods now have an additional handler closure, that allows to configure cells/headers/footers/supplementary views that are dequeued from UICollectionView. This is a direct replacement for configure(_:_:, configureHeader(_:_:), configureFooter(_:_:) and configureSupplementary(_:ofKind:_:, that are all now deprecated.
    • On iOS / tvOS 14 / Xcode 12 and higher handler closure, that is passed to registration methods, is used to call new dequeueConfiguredReusableCell(using:for:item:) and dequeueConfiguredReusableSupplementary(using:for:) methods on UICollectionView. Please note, that handler closure is called before DTModelTransfer.update(with:) method because of how new UICollectionView dequeue API works.
    • ViewModelMapping is now a generic class, that captures view and model information(ViewModelMapping<T,U>).
    • CollectionViewUpdater.batchUpdatesInProgress property was removed.

    Deprecated

    • Several cell/header/footer/supplementary view registration methods have been deprecated to unify registration logic. Please use register(_:mapping:handler:), registerHeader(_:mapping:handler:), registerFooter(_:mapping:handler:) and registerSupplementary(_:forKind:mapping:handler:) as a replacements for all of those methods. For more information on those changes, please read migration guide
    • DTCollectionViewManager.configureEvents(for:_:), it's functionality has become unnecessary since mapping closure of cell/supplementary registration now captures both cell and model type information for such events.
    • DTCollectionViewManager.configureDiffableDataSource(modelProvider:) for non-hashable data models. Please use configureDiffableDataSource method for models, that are Hashable. From Apple's documentation: If you’re working in a Swift codebase, always use UICollectionViewDiffableDataSource instead.

    Fixed

    • Supplementary views now correctly use ViewModelMapping.reuseIdentifier instead of falling back to name of the view class.
    • Several event API's have been improved to allow returning nil for methods, that accept nil as a valid value: contextMenuConfiguration, previewForHighlightingContextMenu, previewForDismissingContextMenu
    Source code(tar.gz)
    Source code(zip)
  • 7.2.0(Jul 2, 2020)

    Changed

    • Deployment targets - iOS 11 / tvOS 11.
    • Minimum Swift version required: 5.0
    • Added support for DTModelStorage/Realm with Realm 5

    Please note, that this framework version source is identical to previous version, which supports iOS 8 / tvOS 9 / Swift 4.2 and higher.

    Source code(tar.gz)
    Source code(zip)
  • 7.1.0(Apr 29, 2020)

    Changed

    • It's not longer necessary to import DTModelStorage framework to use it's API's. import DTCollectionViewManager now implicitly exports DTModelStorage as well.
    Source code(tar.gz)
    Source code(zip)
  • 7.0.0(Nov 8, 2019)

  • 7.0.0-beta.2(Sep 6, 2019)

  • 7.0.0-beta.1(Aug 20, 2019)

    This is a major release with some breaking changes, please read DTCollectionViewManager 7.0 Migration Guide

    Changed

    • DTCollectionViewManager now requires to be built with Swift 4.2 and later.
    • Anomaly event verification now allows subclasses to prevent false-positives.
    • animateChangesOffScreen property on CollectionViewUpdater that allows to turn off animated updates for UICollectionView when it is not on screen.

    Added

    • configureDiffableDataSource(modelProvider:) method to enable UICollectionViewDiffableDataSource with DTCollectionViewManager.
    • DTCollectionViewManager.supplementaryStorage getter, that conditionally casts current storage to SupplementaryStorage protocol.
    • Ability to customize bundle, from which xib files are loaded from by setting bundle property on ViewModelMapping in mappingBlock. As before, bundle defaults to Bundle(for: ViewClass.self).

    New method wrappers for iOS 13 API

    • shouldBeginMultipleSelectionInteraction
    • didBeginMultipleSelectionInteraction
    • didEndMultipleSelectionInteraction
    • contextMenuConfiguration(for:)
    • previewForHighlightingContextMenu
    • previewForDismissingContextMenu
    • willCommitMenuWithAnimator

    Removed

    • Usage of previously deprecated and now removed from DTModelStorage ViewModelMappingCustomizing protocol.

    Breaking

    DTModelStorage header, footer and supplementary model handling has been largely restructured to be a single closure-based API. Read more about changes in DTModelStorage changelog. As a result of those changes, several breaking changes in DTCollectionViewManager include:

    • SectionModel extension with collectionHeaderModel and collectionFooterModel properties has been removed.
    • Because headers/footers are now a closure based API, setSectionHeaderModels and setSectionFooterModels do not create sections by default, and do not call collectionView.reloadData.

    Other breaking changes:

    • collectionViewUpdater will contain nil if DTCollectionViewManager is configured to work with UICollectionViewDiffableDataSource.
    • DTCollectionViewNonOptionalManageable protocol was removed and replaced by collectionView property on DTCollectionViewManageable protocol. One of collectionView/optionalCollectionView properties must be implemented by DTCollectionViewManageable instance to work with DTCollectionViewManager.
    • collectionView property in DTCollectionViewManageable protocol is now ImplicitlyUnwrappedOptional instead of Optional. This change is done to unify API with UICollectionViewController change and DTTableViewManager API for consistency.

    WARNING Because of default implementations for new property this will not show as a compile error, instead crashing in runtime. Please make sure to update all definitions of

    var collectionView: UICollectionView?

    to

    var collectionView: UICollectionView!.

    If you need optional collection view, use optionalCollectionView property instead.

    Deprecated

    Following methods have been deprecated due to their delegate methods being deprecated in iOS 13:

    • shouldShowMenuForItemAt
    • canPerformAction
    • performAction
    Source code(tar.gz)
    Source code(zip)
    DTCollectionViewManager.framework.zip(13.08 MB)
  • 6.6.0(Jun 17, 2019)

  • 6.5.0(Apr 7, 2019)

  • 6.4.2(Feb 5, 2019)

    • move(:_,:_) method was deprecated and no longer works due to a logic bug, that can prevent this method from being called if sourceIndexPath is off screen when this event was called by UICollectionView. Please use new method moveItemAtTo(:_) to subscribe to move events in the datasource.
    Source code(tar.gz)
    Source code(zip)
  • 6.4.1(Oct 30, 2018)

  • 6.4.0(Sep 25, 2018)

  • 6.3.0(Jun 9, 2018)

    Added

    • Anomaly-detecting and reporting system for DTCollectionViewManager. Read more about it in Anomaly Handler Readme section. Anomaly handler system requires Swift 4.1 and higher.
    • Support for Swift 4.2 in Xcode 10 (beta 1).

    Changed

    • Calling startManaging(withDelegate:_) method is no longer required.

    Breaking

    • viewFactoryErrorHandler property on DTCollectionViewManager was removed, all supported errors and warnings are now a part of anomaly reporting system
    Source code(tar.gz)
    Source code(zip)
    DTCollectionViewManager.framework.zip(6.41 MB)
  • 6.1.0-beta.1(Dec 4, 2017)

    • Implemented new system for deferring datasource updates until performBatchUpdates block. This system is intended to fight crash, that might happen when performBatchUpdates method is called after UITableView.reloadData method(for example after calling memoryStorage.setItems, and then immediately memoryStorage.addItems). This issue is detailed in https://github.com/DenHeadless/DTCollectionViewManager/issues/27 and https://github.com/DenHeadless/DTCollectionViewManager/issues/23. This crash can also happen, if iOS 11 API UITableView.performBatchUpdates is used. This system is turned on by default. If, for some reason, you want to disable it and have old behavior, call:
    manager.memoryStorage.defersDatasourceUpdates = false
    

    Please note, though, that new default behavior is recommended, because it is more stable and works the same on both UITableView and UICollectionView.

    • collectionViewUpdater property on DTCollectionViewManager is now of CollectionViewUpdater type instead of opaque StorageUpdating type. This should ease use of this object and prevent type unneccessary type casts.
    Source code(tar.gz)
    Source code(zip)
    DTCollectionViewManager.framework.zip(4.90 MB)
  • 6.0.0(Nov 1, 2017)

  • 6.0.0-beta.3(Oct 5, 2017)

  • 6.0.0-beta.2(Sep 27, 2017)

  • 6.0.0-beta.1(Sep 10, 2017)

    This is a major release with some breaking changes, please read DTTableViewManager 6.0 Migration Guide

    • Added updateVisibleCells(_:) method, that allows updating cell data for visible cells with callback on each cell. This is more efficient than calling reloadData when number of elements in UICollectionView does not change, and only contents of items change.
    • Implement configureEvents(for:_:) method, that allows batching in several cell events to avoid using T.ModelType for events, that do not have cell created.
    • Added DTCollectionViewDropPlaceholderContext wrapper with convenience support for UICollectionView placeholders.
    • Implemented UICollectionViewDragDelegate and UICollectionViewDropDelegate events.
    • Added 10 more UICollectionViewDelegate and UICollectionViewDelegateFlowLayout events.
    • Added missing events for UICollectionViewDatasource protocol: collectionView:moveItemAt:to:, indexTitlesFor:, collectionView:indexPathForIndexTitle:at:
    • Implemented conditional mappings
    • UICollectionViewDelegate and UICollectionViewDatasource implementations have been refactored from DTCollectionViewManager to DTCollectionViewDelegate and DTCollectionViewDataSource classes.
    • Added DTCollectionViewNonOptionalManageable protocol, that can be used with non-optional UICollectionView properties on your managed instance.
    Source code(tar.gz)
    Source code(zip)
    DTCollectionViewManager.framework.zip(5.60 MB)
Owner
Denys Telezhkin
Denys Telezhkin
Automates prefetching of content in UITableView and UICollectionView

Automates preheating (prefetching) of content in UITableView and UICollectionView. Deprecated on iOS 10. This library is similar to UITableViewDataSou

Alexander Grebenyuk 633 Sep 16, 2022
A data-driven UICollectionView framework for building fast and flexible lists.

A data-driven UICollectionView framework for building fast and flexible lists. Main Features ?? Never call performBatchUpdates(_:, completion:) or rel

Instagram 12.5k Jan 1, 2023
Netflix and App Store like UITableView with UICollectionView, written in pure Swift 4.2

GLTableCollectionView Branch Status master develop What it is GLTableCollectionView is a ready to use UITableViewController with a UICollectionView fo

Giulio 708 Nov 17, 2022
Incremental update tool to UITableView and UICollectionView

EditDistance is one of the incremental update tool for UITableView and UICollectionView. The followings show how this library update UI. They generate

Kazuhiro Hayashi 90 Jun 9, 2022
Collapse and expand UICollectionView sections with one method call.

This library provides a custom UICollectionView that allows to expand and collapse sections. Provides a simple API to manage collection view appearanc

Touchlane 172 Dec 26, 2022
🚴 A declarative library for building component-based user interfaces in UITableView and UICollectionView.

A declarative library for building component-based user interfaces in UITableView and UICollectionView. Declarative Component-Based Non-Destructive Pr

Ryo Aoyama 1.2k Jan 5, 2023
UICollectionView layout for presenting of the overlapping cells.

StickyCollectionView UICollectionView layout for presenting of the overlapping cells. Objective-C version here Checkout demo Overview Installation Man

Bogdan Matveev 325 Oct 11, 2022
A generic small reusable components for data source implementation for UITableView/UICollectionView in Swift.

GenericDataSource A generic small reusable components for data source implementation for UITableView/UICollectionView written in Swift. Features Basic

null 132 Sep 8, 2021
Reimagining UICollectionView

CollectionKit Reimagining UICollectionView A modern Swift framework for building composable data-driven collection view. Migration Guide v2.0 Features

SoySauceLab 4.3k Dec 27, 2022
Conv smart represent UICollectionView data structure more than UIKit.

Conv Conv smart represent UICollectionView data structure more than UIKit. Easy definition for UICollectionView DataSource and Delegate methods. And C

bannzai 157 Nov 25, 2022
ZHTCView - UITableview & UICollectionView

ZHTCView 这是一个使用Block替换代理的UITableview & UICollectionView。 使用方法如下: - (DSTableView *)tableView { if (!_tableView) { _tableView = DSTableView.

黑酒一 0 Jan 10, 2022
CollectionView - UICollectionView using UICollectionViewCompositionalLayout

CollectionView UICollectionView using UICollectionViewCompositionalLayout create

null 0 Jan 11, 2022
CollectionViewSegmentedControl - Scrollable UISegmentedControl built using a UICollectionView

CollectionViewSegmentedControl Installation CocoaPods Download CocoaPods Run 'Po

James Sedlacek 7 Nov 24, 2022
Conv smart represent UICollectionView data structure more than UIKit.

Conv Conv smart represent UICollectionView data structure more than UIKit. Easy definition for UICollectionView DataSource and Delegate methods. And C

bannzai 155 May 12, 2022
A modest attempt to port UICollectionView to SwiftUI.

LazyCollectionView A modest attempt to port UICollectionView to SwiftUI. Table of Contents Description Requirements Installation Usage Components Impr

Unsplash 109 Dec 27, 2022
Easy and type-safe iOS table and collection views in Swift.

Quick Start TL;DR? SimpleSource is a library that lets you populate and update table views and collection views with ease. It gives you fully typed cl

Squarespace 96 Dec 26, 2022
A SwiftUI collection view with support for custom layouts, preloading, and more.

ASCollectionView A SwiftUI implementation of UICollectionView & UITableView. Here's some of its useful features: supports preloading and onAppear/onDi

Apptek Studios 1.3k Dec 24, 2022
A Swift mixin for reusing views easily and in a type-safe way (UITableViewCells, UICollectionViewCells, custom UIViews, ViewControllers, Storyboards…)

Reusable A Swift mixin to use UITableViewCells, UICollectionViewCells and UIViewControllers in a type-safe way, without the need to manipulate their S

Olivier Halligon 2.9k Jan 3, 2023
TLIndexPathTools is a small set of classes that can greatly simplify your table and collection views.

TLIndexPathTools TLIndexPathTools is a small set of classes that can greatly simplify your table and collection views. Here are some of the awesome th

SwiftKick Mobile 347 Sep 21, 2022