forked from shadowfacts/Tusker
Fix asset preview size
This commit is contained in:
parent
1ccb450477
commit
0691c3b9d6
|
@ -170,12 +170,22 @@ class AssetCollectionViewController: UICollectionViewController {
|
|||
return nil
|
||||
} else {
|
||||
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)
|
||||
}, 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
|
||||
|
||||
@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
|
||||
DispatchQueue.main.async {
|
||||
imageView.image = image
|
||||
self.preferredContentSize = image!.size
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,6 +91,7 @@ class AssetPreviewViewController: UIViewController {
|
|||
livePhotoView.topAnchor.constraint(equalTo: self.view.topAnchor),
|
||||
livePhotoView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor)
|
||||
])
|
||||
self.preferredContentSize = livePhoto.size
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -111,6 +113,7 @@ class AssetPreviewViewController: UIViewController {
|
|||
player.play()
|
||||
playerController.player = player
|
||||
self.embedChild(playerController)
|
||||
self.preferredContentSize = item.presentationSize
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue