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
iOS 13 Set Uisearchtextfield Placeholder Color
Chrome for iOS User Agent on iPad
Programmatically Sending an App to Background
What Is Difference Between Self.Timer = Nil VS [Self.Timer Invalidate] in iOS
How to Make a Conical Gradient in iOS Using Core Graphics/Quartz 2D
Parsing JSON Using the New Swift 3 and Alamofire
Admob 7.3.1 and Swift 2.0 - Module Not Found
Autolayout Ignores Multi-Line Detailtextlabel When Calculating Uitableviewcell Height (All Styles)
Stop Skaction That Repeatsforever - Sprite Kit
Uiwebview Stringbyevaluatingjavascriptfromstring Hangs on iOS5.0/5.1 When Called Using Gcd
Animating Calayer's Shadowpath Property
How to Get an Error Description When Playback Fails on Mpmovieplayercontroller