Skip to content

Commit bff2d06

Browse files
committed
Fixes an iOS14 bug in ComposedMediaUI
Adds diffing support to SegmentedSectionProvider which provides animation between updates Inserts/Removes now shift the index as required to ensure index consistency Updated the Demo app to showcase the new SegmentedSectionProvider updates
1 parent 12d4852 commit bff2d06

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Sources/ComposedMediaUI/MediaViewController.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ open class MediaViewController: UIViewController {
5757
open override func viewDidLoad() {
5858
super.viewDidLoad()
5959

60+
let provider = ComposedSectionProvider()
61+
let options = PHFetchOptions()
62+
options.sortDescriptors = [NSSortDescriptor(keyPath: \PHAsset.creationDate, ascending: false)]
63+
64+
provider.append(MediaAssetSection(fetchResult: PHAsset.fetchAssets(with: options), imageManager: imageManager))
65+
collectionCoordinator = CollectionCoordinator(collectionView: collectionView, sectionProvider: provider)
66+
67+
updateNavigationItems(editing: false, animated: false)
68+
6069
if #available(iOS 13.0, *) {
6170
collectionView.backgroundColor = .systemBackground
6271
} else {
@@ -69,15 +78,6 @@ open class MediaViewController: UIViewController {
6978
collectionView.delegate = self
7079
collectionView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
7180
view.addSubview(collectionView)
72-
73-
let provider = ComposedSectionProvider()
74-
let options = PHFetchOptions()
75-
options.sortDescriptors = [NSSortDescriptor(keyPath: \PHAsset.creationDate, ascending: false)]
76-
77-
provider.append(MediaAssetSection(fetchResult: PHAsset.fetchAssets(with: options), imageManager: imageManager))
78-
collectionCoordinator = CollectionCoordinator(collectionView: collectionView, sectionProvider: provider)
79-
80-
updateNavigationItems(editing: false, animated: false)
8181
}
8282

8383
@objc private func beginEditing(_ sender: Any?) {

0 commit comments

Comments
 (0)