How to Disable Qlpreviewcontroller Print Button

QLPreviewController remove or add UIBarButtonItems

Update:

This no longer works in iOS 6. Quick Look runs in another process using XPC. See here for more details. I don't foresee any way to customize QLPreviewController. The following answer remains for anyone interested for pre-iOS 6.


I answered an almost identical question the other day here. The question pertained to removing the print button, which isn't too hard. One thing to note about QLPreviewController is that it's not meant to be customized. I have built a subclass of QLPreviewController that can be customized. I've put it here on Github. It's designed to easily remove the action button, among other features too. It wouldn't take much effort at all to replace the button with a custom one.

The biggest thing to watch out for is that the action button is re-added to the navigation bar anytime a new document is displayed. You should notice this in my code. Anytime RBFilePreviewer removes the action button, you just need to re-add your custom buttons. To add your custom buttons, you should create a UIBarButtonItem that holds a custom view with four buttons in it. Then set the right bar button item as the custom UIBarButtonItem you created.

Update:

I've updated RBFilePreviewer to allow you to set a custom right bar button item right out-of-the-box. Just call -setRightBarButtonItem: on RBFilePreviewer and it just works.

Is it possible to Disable Open In... for a generated PDF in iOS preview

Yes, it can be done. You need to create a subclass of QLPreviewController and assign your own button to self.rightBarButtonItem in viewWillAppear and viewDidAppear. In addition, your class should listen for UIApplicationDidEnterBackgroundNotification and UIApplicationWillEnterForegroundNotification and do the same thing in the callback method(s) for those notifications.

You can replicate the print button functionality with UIPrintInteractionController.



Related Topics



Leave a reply



Submit