You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## UITableView Cell and Header/Footer registration
43
+
## UITableView Cell Registration
44
44
45
-
A registration for the table view’s cells and header/footer views similar to `UICollectionView.CellRegistration`.
45
+
A registration for the table view’s cells similar to `UICollectionView.CellRegistration`.
46
46
47
47
Use a cell registration to register table cell views with your table view and configure each cell for display.
48
48
@@ -59,11 +59,64 @@ let cellRegistration = UITableView.CellRegistration<UITableViewCell, String> { c
59
59
}
60
60
```
61
61
62
-
After you create a cell registration, you pass it in to ``UIKit/UITableView/dequeueConfiguredReusableCell(using:for:item:)``, which you call from your data source’s cell provider.
62
+
After you create a cell registration, you pass it in to ``dequeueConfiguredReusableCell(using:for:item:)``, which you call from your data source’s cell provider.
Alternatively you can use the ``UICollectionViewDiffableDataSource`` and ``UITableViewDiffableDataSource`` initializers:
72
+
73
+
```swift
74
+
let dataSource =UITableViewDiffableDataSource(tableView: myTableView, cellRegistration: cellRegistration)
75
+
}
76
+
```
77
+
78
+
## UITableView Header/Footer View Registration
79
+
80
+
A registration for the table view’s header/footer views.
81
+
82
+
```swift
83
+
let sectionViewRegistration = UITableView.SectionViewRegistration<UITableViewHeaderFooterView, String> {
84
+
sectionView, indexPath, string in
85
+
86
+
var configuration = sectionView.defaultContentConfiguration()
87
+
configuration.text= string
88
+
sectionView.contentConfiguration= configuration
89
+
}
90
+
```
91
+
92
+
After you create a section view registration, you pass it in to ``dequeueConfiguredReusableSectionView(using:section:)``, which you call from your data source’s section header view provider.
93
+
94
+
```swift
95
+
dataSource.headerViewProvider= { tableView, section in
0 commit comments