Is there a way to add a cancel button to `QLPreviewController`

318 Views Asked by At

I want to use QLPreviewController to edit images in my app. Just using vanilla code to present this:

override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
    collectionView.deselectItem(at: indexPath, animated: true)
    let quickLookViewController = QLPreviewController()
    quickLookViewController.dataSource = self
    quickLookViewController.delegate = self
    tappedCell = collectionView.cellForItem(at: indexPath) as? FileCell
    quickLookViewController.currentPreviewItemIndex = indexPath.row
    present(quickLookViewController, animated: true)
}

The result is as follows:

enter image description here

Is there a way to add cancel button functionality to the QLPreviewController? I've heard of putting it in a navigation controller and then adding buttons to the bar, but I don't want to do this since it's hacky and causes strange transition animation issues.

It seems strange there isn't a cancel button by default since if you annotate a photo form within the iOS photos app it provides both a "Done" and a "Cancel" button.

0

There are 0 best solutions below