Can anyone tell me how to remove the QLPreviewController print button? Also would like to disable cut/paste/copy.
相关问题
- Correctly parse PDF paragraphs with Python
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
- didBeginContact:(SKPhysicsContact *)contact not in
- Attempt to present UIAlertController on View Contr
Works for me instead of
[[self navigationItem] setRightBarButtonItem:nil];
this work for me . you have to debugg child navigation controller
UPDATE:
This no longer works in iOS 6. Quick Look runs in another process using XPC. See [here][3] for more details. I don't foresee any way to customize QLPreviewController. The following answer remains for anyone interested for pre-iOS 6.
If you want to simply remove the action button you need to subclass
QLPreviewController
. Then in-viewWillAppear:
you need to remove the action button by calling[[self navigationItem] setRightBarButtonItem:nil];
This will also remove the ability to share files with other apps. If you are fine with that loss, then that's the easiest solution. One thing to be aware of is thatQLPreviewController
is NOT intended to be customized. You can check out this repository on Github. It contains a QLPreviewController that is already safely subclassed. You just need to add the one line to remove the action button. The repo also has some other conveniences.The better but more complicated solution is to use
UIDocumentInteractionController
. From what I understand ofQLPreviewController
is that it's built usingUIDocumentInteractionController
.QLPreviewController
was made for general use and easy addition.UIDocumentInteractionController
gives much more control, but is harder to use. I can't sufficiently describe how to use it here. I recommend checking out WWDC 2010 session 106 Understanding Document Interaction Controller.As for disabling cut/copy/paste, you can't do that with
QLPreviewController
. You might be able to do that withUIDocumentInteractionController
, but I wouldn't count on it. Depending on what files you want to display, you may be able to do a completely custom implementation, but that's a lot of work. It's relatively easy to make viewers for plain text, photos, videos, and PDFs. Office documents are more effort than it's worth.EDIT:
I've built the ability to remove the action button right into
RBFilePreviewer
so you don't have to worry about doing it yourself.If you subclass
QLPreviewController
and then add this one method:in the subclass, the action button will disappear as rbrown notes above. This will not work if you use
viewWillAppear
. Also, an unexpected side-effect of doing this is that the toolbar on the preview now appears at all times, instead of just when you tap the view.I also need to custom the navigaiton item of
QLPreviewController
. Just like rbrown said, XPC is used and we can no longer add custom items inviewDidLoad
orviewWillAppear
.Currently I use this way:
UIViewController
QLPreviewController
to the new classIt seems wired but works.
This subclass works with Swift 4.2 and iOS 12. It uses a trick to make sure that the share icon is hidden without flashing in the eyes of the user.