I am subclassing QLPreviewController in my application and using the following code.
QLPreviewControllerSubClass* preview = [[QLPreviewControllerSubClass all
Tested on iOS 9 with swift.
Recently had to solve this issue and had trouble finding a way to hide this dang button. I finally managed to hide the right share button using an answer from this stackoverflow post.
Basically, you want to subclass QLPreviewController and call the inspectSubviewForView() function in your viewWillAppear() function. Once you find the navigation item containing the share button, you can remove it:
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
// ** traverse subviews until we find the share button ** //
inspectSubviewForView(self.view)
}
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] {
// ** Found the share button, hide it! ** //
hideRightBarItem(navItem)
}
}
}
if subview.subviews.count > 0 {
// ** this subview has more subviews! Inspect them! ** //
inspectSubviewForView(subview)
}
}
}
func hideRightBarItem(navigationItem: UINavigationItem) {
// ** Hide/Remove the Share button ** //
navigationItem.setRightBarButtonItem(nil, animated: false)
}
The previous poster from the above link warned that this may not get through apple's review process as you are accessing private APIs, so use at your own risk! Also if Apple updates the QLPreviewController in later versions of iOS this code may no longer work.
Still, this is the only solution that has worked for me. I hope it works for you too!