2011-03-18 165 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认为您已停止响应输入并杀死您的应用。