4
我試着去找到一個功能,讓我打印使用AirPrint功能。功能發送圖像到支持AirPrint
我有一個按鈕btnPrint
,按下時,應打印myPic.jpg到默認AirPrint的設備。但我無法弄清楚是否有這樣的功能。
我找不到在Xcode上的AirPrint大量的文檔資料。
我試着去找到一個功能,讓我打印使用AirPrint功能。功能發送圖像到支持AirPrint
我有一個按鈕btnPrint
,按下時,應打印myPic.jpg到默認AirPrint的設備。但我無法弄清楚是否有這樣的功能。
我找不到在Xcode上的AirPrint大量的文檔資料。
蘋果documentation on printing這將可能使你受益。
而下面是Objective-C code for AirPrint:
請檢查是否打印可用:後
if ([UIPrintInteractionController isPrintingAvailable])
{
// Available
} else {
// Not Available
}
打印按鈕點擊:
-(IBAction) buttonClicked: (id) sender;
{
NSMutableString *printBody = [NSMutableString stringWithFormat:@"%@, %@",self.encoded.text, self.decoded.text];
[printBody appendFormat:@"\n\n\n\nPrinted From *myapp*"];
UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
pic.delegate = self;
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.jobName = self.titleLabel.text;
pic.printInfo = printInfo;
UISimpleTextPrintFormatter *textFormatter = [[UISimpleTextPrintFormatter alloc] initWithText:printBody];
textFormatter.startPage = 0;
textFormatter.contentInsets = UIEdgeInsetsMake(72.0, 72.0, 72.0, 72.0); // 1 inch margins
textFormatter.maximumContentWidth = 6 * 72.0;
pic.printFormatter = textFormatter;
[textFormatter release];
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 presentFromBarButtonItem:self.rightButton animated:YES completionHandler:completionHandler];
}
嗨,我正在實施相同的。但我想知道是否有任何方法可以知道打印已完成?有沒有任何委託方法? –
這個問題是不相關的Xcode。 – 2012-09-07 13:32:12