1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// AirPrintManager.m
// Lighting
//
// Created by 曹云霄 on 2016/11/10.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "AirPrintManager.h"
@implementation AirPrintManager
/**
打印URL订单
@param data 数据源
@param finish 完成
@param failed 失败
*/
+ (void)printOrderWithdataSoure:(UIViewPrintFormatter *)data printSuccess:(void(^)())finish printError:(void(^)())failed
{
UIPrintInteractionController *printControl = [UIPrintInteractionController sharedPrintController];
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.jobName = @"订单明细";
printInfo.duplex = UIPrintInfoDuplexShortEdge;
printControl.printInfo = printInfo;
printControl.showsPageRange = YES;
printControl.printFormatter = data;
void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *pic, BOOL completed, NSError *error) {
if (completed)
{
// 执行成功后的处理
finish();
}
else if (!completed && error)
{
// 执行失败后的处理
failed();
}
};
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
[printControl presentAnimated:YES completionHandler:completionHandler];
}
}
@end