Custom printing options using AirPrint and UIPrintInteractionController

4.1k Views Asked by At

I've successfully added printing capabilities to an iPad application that makes use of the UIPrintInteractionController class. Things work well, and a standard document is printed.

There are a couple BOOL properties that can be defined for a print job in my application, however. (Turning on certain features, adding additional layout schemes, etc.)

How can these options be presented/modified by the user using the UIPrintInteractionController? The perfect solution would be to add a couple switch table view cells to the UITableView that is presented in that controller, but this doesn't seem to be allowed by the API.

Edit: This is the view I'm referring to:

enter image description here

3

There are 3 best solutions below

1
On BEST ANSWER

It looks like the best bet (so far) is to assign a delegate to the UIPrintInteractionController, and have that delegate implement the method:

- (UIViewController *)printInteractionControllerParentViewController:(UIPrintInteractionController *)printInteractionController

If the delegate returns an instance of a UINavigationController, then instead of being presented modally, it can be pushed from a UITableViewController subclass that provides a list of options.

From the UIPrintInteractionControllerDelegate class reference:

UIKit can push the returned view controller onto the stack if its parent is a navigation controller or present it modally if it isn’t.

UIPrintInteractionControllerDelegate Class Reference

0
On

You could try to subclass UIPrintInteractionController, there's no hint in the Class Reference that it's not possible.

0
On

Use printInteractionControllerParentViewController, the trick is to declare a UINavigationController *aNav; in .h and then in viewDidLoad do aNav = [self UINavigationController]; this will save the navigationController handle (assuming self is a UITableViewController with UINavigationController setup ok).

Then after invoke the uiprinterinteraction, do aNav.topViewController.viw.backgroundColor = [UIColor redColor]; to change the uiprinterinteraction background color to red.

Lastly, in printInteractionControllerParentViewController do a return aNav;

Now you have successfully change the background color of the AirPrint ui.

By using this aNav, you can do a lot of thing.