Мне нужно AirPrint в Xcode в фоновом режиме без взаимодействия с пользователем. Мне все равно, нужно ли мне использовать стороннюю структуру для этого. Вот код, который у меня есть, но требует взаимодействия пользователя.автоматический AirPrint IOS
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];
Если кто-нибудь может помочь, это было бы здорово!
Вы хотите распечатать автоматический без каких-либо действий? – iOS
Вы смотрите здесь ?: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIPrintInteractionController_Class/index.html#//apple_ref/occ/instm/UIPrintInteractionController/printToPrinter:completionHandler: – tptcat
Да @ DarjiJigar это то, что я хочу сделать – Connor