[IOS 开发] 关于ios打印(AirPrint)

来源:互联网 发布:淘宝拍摄布光 编辑:程序博客网 时间:2024/04/29 16:35

导入 UIPrintInteractionController 类

在.h中实现它的代理Delegate <UIPrintInteractionControllerDelegate>


例子:

UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];        if  (pic) {        pic.delegate = self;        UIPrintInfo *printInfo = [UIPrintInfo printInfo];        printInfo.outputType = UIPrintInfoOutputGeneral;        printInfo.jobName = @"111";        printInfo.duplex = UIPrintInfoDuplexLongEdge;        pic.printInfo = printInfo;        pic.showsPageRange = YES;        //可以是多张图片        pic.printingItems = dataArr;                void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) =^(UIPrintInteractionController *pic, BOOL completed, NSError *error) {if (!completed && error)NSLog(@"FAILED! due to error in domain %@ with error code %u",  error.domain, error.code);};                if (iPad) {            [pic presentFromRect:sender.frame inView:self.window animated:YES completionHandler:completionHandler];        }else        {            [pic presentAnimated:YES completionHandler:completionHandler];                    }    }


0 0
原创粉丝点击