源码
无意中玩一个demo发现调用了打印机 才发现ios有快速调用打印机的功能.
if ([UIPrintInteractionController isPrintingAvailable] == YES)
{
NSURL *fileURL = document.fileURL; // Document file URL if ([UIPrintInteractionController canPrintURL:fileURL] == YES)
{
printInteraction = [UIPrintInteractionController sharedPrintController]; UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.duplex = UIPrintInfoDuplexLongEdge;
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.jobName = document.fileName; printInteraction.printInfo = printInfo;
printInteraction.printingItem = fileURL;
printInteraction.showsPageRange = YES; if (userInterfaceIdiom == UIUserInterfaceIdiomPad) // Large device printing
{
[printInteraction presentFromRect:button.bounds inView:button animated:YES completionHandler:
^(UIPrintInteractionController *pic, BOOL completed, NSError *error)
{
#ifdef DEBUG
if ((completed == NO) && (error != nil)) NSLog(@"%s %@", __FUNCTION__, error);
#endif
}
];
}
else // Handle printing on small device
{
[printInteraction presentAnimated:YES completionHandler:
^(UIPrintInteractionController *pic, BOOL completed, NSError *error)
{
#ifdef DEBUG
if ((completed == NO) && (error != nil)) NSLog(@"%s %@", __FUNCTION__, error);
#endif
}
];
}
}
}