У меня проблемы с печатью на iPad.Мой код впервые печатает PDF-файл;но когда я печатаю свой pdf-файл во второй раз, приложение зависает, а затем вылетает.
Below is my code:
NSData *myPdfData = [NSData dataWithContentsOfFile:pdfPath];
UIPrintInteractionController *controller = [UIPrintInteractionController sharedPrintController];
if (controller && [UIPrintInteractionController canPrintData:myPdfData]){
controller.delegate = delegate;
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.jobName = [pdfPath lastPathComponent];
printInfo.duplex = UIPrintInfoDuplexLongEdge;
controller.printInfo = printInfo;
controller.showsPageRange = YES;
controller.printingItem = myPdfData;
// We need a completion handler block for printing.
UIPrintInteractionCompletionHandler completionHandler = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
if(completed && error){
NSLog(@"FAILED! due to error in domain %@ with error code %u", error.domain, error.code);
}
};
[controller presentFromRect:[sender frame] inView:senderView animated:YES completionHandler:completionHandler];
}else {
NSLog(@"Couldn't get shared UIPrintInteractionController!");
}
Ниже приведена трассировка стека с устройства:
D
ate/Time: 2011-03-17 20:48:02.523 -0700
OS Version: iPhone OS 4.3 (8F190)
Report Version: 104
Exception Type: 00000020
Exception Codes: 0x8badf00d
Highlighted Thread: 0
Application Specific Information:
Brighton failed to resume in time
Elapsed total CPU time (seconds): 2.310 (user 0.290, system 2.020), 23% CPU
Elapsed application CPU time (seconds): 0.000, 0% CPU
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0:
0 libsystem_kernel.dylib 0x30bd2ab0 0x30bc2000 + 68272
1 PrintKit 0x313f2c1a 0x313df000 + 80922
2 PrintKit 0x313ee9ea 0x313df000 + 63978
3 PrintKit 0x313eea90 0x313df000 + 64144
4 PrintKit 0x313eeab4 0x313df000 + 64180
5 PrintKit 0x313e4f96 0x313df000 + 24470
6 PrintKit 0x313e266a 0x313df000 + 13930
7 UIKit 0x335e3656 0x33311000 + 2958934
8 UIKit 0x335e904c 0x33311000 + 2981964
9 UIKit 0x335e8bcc 0x33311000 + 2980812
10 UIKit 0x335e99fc 0x33311000 + 2984444
11 UIKit 0x3343460c 0x33311000 + 1193484
12 Foundation 0x30d306ce 0x30cab000 + 546510
13 CoreFoundation 0x31c43a40 0x31bce000 + 481856
14 CoreFoundation 0x31c45ec4 0x31bce000 + 491204
15 CoreFoundation 0x31c4683e 0x31bce000 + 493630
16 CoreFoundation 0x31bd6ebc 0x31bce000 + 36540
17 CoreFoundation 0x31bd6dc4 0x31bce000 + 36292
18 GraphicsServices 0x32dbf418 0x32dbb000 + 17432
19 GraphicsServices 0x32dbf4c4 0x32dbb000 + 17604
Было бы очень полезно, если бы кто-нибудь помог мне разобраться в проблеме.
Заранее спасибо!