I have an iOS app I'm writing for the iPad/iPhone. I'm generating a PDF report for printing, and have everything working, where the app will successfully open the generated PDF in QLPreviewController, I am using the following code to open the preview:
// open a preview of the PDF File.
QLPreviewController* preview = [[QLPreviewController alloc] init];
preview.dataSource = self;
[self presentModalViewController:preview animated:YES];
After the PDF is opened in Preview, you have the standard buttons on the Preview toolbar. The buttons are "Done" and an "Action Button" for printing/opening the pdf in other apps.
I included a screenshot of what I'm talking about.
My question is, is there a quick way to disable/disallow the "Open in 'iBooks'" and "Open In..." options? I want to only allow the user to print the pdf. I know I can send the pdf directly to print without opening preview, but I want to allow the user to preview the pdf prior to printing. So really, I just need to disable the "open in" options. Thanks!
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
.