2011-03-18 77 views
1

我在打印ipad時遇到了麻煩。我的代碼第一次完美打印PDF文件;但是當我第二次打印我的pdf文件時,應用程序凍結,然後崩潰。ipad上的空氣打印崩潰

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 

這將是真正有用的,如果有人可以幫我找出這個問題。

在此先感謝!

回答

2

線索在這:「布賴頓未能及時恢復。」

打印完成後,控件將返回到您的應用程序,但您需要很長時間才能響應。 iOS認爲您已停止響應輸入並殺死您的應用。