iosswiftqlpreviewcontroller

How to Customize QuickLook(QLPreviewControlller) navigation bar?


I am trying to remove all the right-side BarButtonItem in QuickLook (QLPreviewController) in iOS 15 and Xcode 13.2 and later.

My requirement is to only show search button in right-side of navigation bar. I tried many types of solutions but I'm not able to meet this requirement. I also read QuickLook Document provided by Apple but I'm not having success. For more understanding show this Apple document: Apple QuickLook Document Link.

This is the image


Solution

  • If you want to remove the ability to edit a document while using QLPreviewController, you need to implement the previewController(_:editingModeFor:) delegate method.

    Make sure you set the delegate property of your QLPreviewController (along with the dataSource).

    Then implement:

    func previewController(_ controller: QLPreviewController, editingModeFor previewItem: QLPreviewItem) -> QLPreviewItemEditingMode {
        return .disabled
    }
    

    This will disable editing and remove the edit icon next to the search icon.