0
我是xcode的初学者,我想使用Air Print打印我的目标C应用程序。这是我目前的代码。空气打印图像目标c
-(IBAction)Print {
UIImage *image = [UIImage imageNamed:@"picTwizzlerfw.png"];
NSMutableString *printBody = [NSMutableString stringWithFormat:@"%@",_TextField.text];
UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
//pic.delegate = self;
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.jobName = @"PrintJob";
pic.printInfo = printInfo;
UISimpleTextPrintFormatter *textFormatter = [[UISimpleTextPrintFormatter alloc] initWithText:printBody];
textFormatter.startPage = 0;
textFormatter.contentInsets = UIEdgeInsetsMake(72.0, 72.0, 72.0, 72.0);
textFormatter.maximumContentWidth = 6 * 72.0;
pic.printFormatter = textFormatter;
pic.showsPageRange = YES;
void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
if (!completed && error) {
NSLog(@"Printing could not complete because of error: %@", error);
}
};
[pic presentAnimated:YES completionHandler:completionHandler];
}
现在它正在打印TextField
,但我希望它打印image
。如果有人能帮上忙,那就太棒了!
为什么不使用'UIActivityViewController'与图像?然后,用户可以选择他们想要对图像执行的任何操作,包括打印。 – rmaddy