Comments (3)
Hi @lingzlu have you taken a look at using a datasource? Something like:
let dataSource = RxCollectionViewSectionedReloadDataSource<YourCustomSectionModel>
There's a pretty good example in the examples on it.
You could then do the same kind of thing from the examples:
func skinTableViewDataSource(dataSource: RxCollectionViewSectionedReloadDataSource<YourCustomSectionModel>) { dataSource.configureCell = { (dataSource, table, idxPath, item) in
switch dataSource.itemAtIndexPath(idxPath) {
case RegularCell:
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "RegularCell", for: indexPath) as! RegularCell
// configure regular cell
return cell
case SepcialCell:
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "SpecialCell", for: indexPath) as! SpecialCell
// this cell has different layout with no SectionModel item, configureCell does not get called
return cell
Then in your viewDidLoad you'll want to have some sort of observable of (regular) [SectionItem]
that maps to [YourCustomSectionModel]
which you would bind to collectionView.rx_itemsWithDataSource(dataSource)
.map{ regularSectionItems -> [YourCustomSectionModel] in
let specialCell = SectionItem.SpecialSectionItem()
let specialSection = YourCustomSectionModel.SpecialSection(title: "Special", items: [specialCell])
let regularSection = YourCustomSectionModel.RegularSection(title: "Regular", items: regularSectionItems)
return [regularSection, specialSection]}
.bindTo(collectionView.rx_itemsWithDataSource(dataSource))
.addDisposableTo(disposeBag)
Give that a shot
from rxdatasources.
thank gkuhlmann14! I model the example on MultipleSectionModelViewController.swift, and got something working, only problem is that I had to give SectionModel for special cell a dummy item to trigger the configureCell.
from rxdatasources.
This looks resolved.
from rxdatasources.
Related Issues (20)
- Issues that result in two section header
- RxTableViewSectionedAnimatedDataSource dataSource sectionModels are always same with newSections HOT 2
- [Carthage] IPHONEOS_DEPLOYMENT_TARGET on Xcode project does not match the SPM target. HOT 1
- RxDataSources collapses HOT 1
- Different version in .podspec from release tag HOT 3
- Reload all but one section
- RxDataSources not supported swift version 5.5.2 HOT 2
- Binding multiple data and cells in RxSwiftDataSource (attempt to insert section 0 but there are only 0 sections after the update)
- .github/workflows/swift.yml HOT 1
- Package.swift HOT 1
- dotnet new console --name OctocatApp
- RxCollectionViewSectionedAnimatedDataSource crash if estimatedItemSize was set in iOS 14.0&14.0.1
- Lack of support UICollectionView delegate method `contextMenuConfigurationForItemAt`or `contextMenuConfigurationForItemsAt`
- IdentifiableType with Unidirectional Data Flow HOT 2
- Question about items function parameters
- Altstore
- CHANGELOG doesn't seem to show you have a 5.0.0 release?
- About customizing row height for RxPickerViewViewAdapter.
- textView in tableView cell
- Privacy Manifest HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxdatasources.