I'm currently displaying a PDF file using the Quick Look framework on an iPad via the Modal View Controller. Works great. My problem is that since I'm displaying a PDF file the Quick Look preview is automatically adding a "Print" button. What I would like to do is replace the "Print" button with a custom "Email" button. Is this something that can be done? At first pass I thought this was going to be a somewhat trivial thing to do but at this point I'm really struggling with it. Any help would be greatly appreciated.
Thanks,
Brett
Since QLPreviewController is a subclass of UIViewController, you can take advantage of -[UIViewController setToolbarItems:] to customize the toolbar.
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemReply target:self action:@selector(emailPDF)];
NSArray *items = [NSArray arrayWithObject:item];
[previewController setToolbarItems:items animated:NO];
[[self navigationController] presentModalViewController:previewController animated:YES];
Now when the user taps the "reply" icon in the toolbar, your implementation of -emailPDF will get called.
you can create a subclass of QLPreviewController like MyQLPreviewController
Then in viewWillAppear:(BOOL)animated (IMPORTANT!!)
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
UIBarButtonItem *rightRatain = self.navigationItem.rightBarButtonItem;
UIBarButtonItem *email = ...;
self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:right, email, nil];
[email release];
}