Fix asset preview size
This commit is contained in:
parent
1ccb450477
commit
0691c3b9d6
|
@ -170,12 +170,22 @@ class AssetCollectionViewController: UICollectionViewController {
|
||||||
return nil
|
return nil
|
||||||
} else {
|
} else {
|
||||||
let asset = fetchResult.object(at: indexPath.row - 1)
|
let asset = fetchResult.object(at: indexPath.row - 1)
|
||||||
return UIContextMenuConfiguration(identifier: nil, previewProvider: { () -> UIViewController? in
|
return UIContextMenuConfiguration(identifier: indexPath as NSIndexPath, previewProvider: { () -> UIViewController? in
|
||||||
return AssetPreviewViewController(asset: asset)
|
return AssetPreviewViewController(asset: asset)
|
||||||
}, actionProvider: nil)
|
}, actionProvider: nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func collectionView(_ collectionView: UICollectionView, previewForHighlightingContextMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? {
|
||||||
|
if let indexPath = (configuration.identifier as? NSIndexPath) as IndexPath?, let cell = collectionView.cellForItem(at: indexPath) {
|
||||||
|
let parameters = UIPreviewParameters()
|
||||||
|
parameters.backgroundColor = .black
|
||||||
|
return UITargetedPreview(view: cell, parameters: parameters)
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Interaction
|
// MARK: - Interaction
|
||||||
|
|
||||||
@objc func donePressed() {
|
@objc func donePressed() {
|
||||||
|
|
|
@ -63,6 +63,7 @@ class AssetPreviewViewController: UIViewController {
|
||||||
PHImageManager.default().requestImage(for: asset, targetSize: view.bounds.size, contentMode: .aspectFit, options: options) { (image, _) in
|
PHImageManager.default().requestImage(for: asset, targetSize: view.bounds.size, contentMode: .aspectFit, options: options) { (image, _) in
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
imageView.image = image
|
imageView.image = image
|
||||||
|
self.preferredContentSize = image!.size
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,6 +91,7 @@ class AssetPreviewViewController: UIViewController {
|
||||||
livePhotoView.topAnchor.constraint(equalTo: self.view.topAnchor),
|
livePhotoView.topAnchor.constraint(equalTo: self.view.topAnchor),
|
||||||
livePhotoView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor)
|
livePhotoView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor)
|
||||||
])
|
])
|
||||||
|
self.preferredContentSize = livePhoto.size
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,6 +113,7 @@ class AssetPreviewViewController: UIViewController {
|
||||||
player.play()
|
player.play()
|
||||||
playerController.player = player
|
playerController.player = player
|
||||||
self.embedChild(playerController)
|
self.embedChild(playerController)
|
||||||
|
self.preferredContentSize = item.presentationSize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue