I am subclassing QLPreviewController in my application and using the following code.
QLPreviewControllerSubClass* preview = [[QLPreviewControllerSubClass all
Thanks to Matthew Kostelecky, i was able to hide the share button but i would like to add some details for those need this in universal apps with multiple files.
Firstly Matthew's answer works if you use QLPreviewController modally. If you push QLPreviewController from your navigation controller like this;
navigationController?.pushViewController(quickLookController, animated: true)
It wont be able to find any NavigationBar or ToolBar. You should call QLPreviewController modally like this;
presentViewController(quickLookController, animated: true, completion: nil)
Also if you are developing universal app and you have list of files to play. There will be another button(List Button);
In iPhones if you have multiple files, QLPreviewController will create toolbar to show "List Button" and "Share Button" and both of these will be on ToolBar.
In iPads both of these buttons are on NavigationBar and there is no ToolBar.
So addition to Matthew's answer you should search toolBar if you have multiple files in iphone;
func inspectSubviewForView(view: UIView) {
for subview in view.subviews {
if subview is UINavigationBar {
// ** Found a Nav bar, check for navigation items. ** //
let bar = subview as! UINavigationBar
if bar.items?.count > 0 {
if let navItem = bar.items?[0] {
navItem.setRightBarButtonItem(nil, animated: false)
}
}
}
if subview is UIToolbar {
// ** Found a Tool bar, check for ToolBar items. ** //
let bar = subview as! UIToolbar
if bar.items?.count > 0 {
if let toolBarItem = bar.items?[0] {
toolBarItem.enabled = false
}
}
}
if subview.subviews.count > 0 {
// ** this subview has more subviews! Inspect them! ** //
inspectSubviewForView(subview)
}
}
}
This piece of code will hide share button on iPad and disable share button on iPhone.
Hope it helps to those still need it.