2015-11-13 66 views
2

我在這個極其奇怪的問題上掙扎了好幾天。下面是初始化和呈現打印對話框,它的iOS 9之前,工作完美的標準代碼:iOS 9:UIPrintInteractionController演示文稿問題

- (void)setupPrinting:(UIPrintInteractionController *)aPrintController 
{ 
    NSString *text = [self formattedHTMLforPrinting]; 
    UIMarkupTextPrintFormatter *formatter = [[[UIMarkupTextPrintFormatter alloc] initWithMarkupText:text] autorelease]; 
    aPrintController.printFormatter = formatter; 
} 


- (IBAction)printContent:(id)aSender { 
    if ([UIPrintInteractionController isPrintingAvailable]) { 
     UIPrintInteractionController *printController = [UIPrintInteractionController sharedPrintController]; 
     printController.delegate = self; 
     [self setupPrinting:printController]; 

//tried different ways to present print controller 
//  [printController presentAnimated:NO completionHandler:nil]; 
//  [printController presentFromRect:self.view.bounds inView:self.view animated:YES 

//these two lines are just to make sure printButton is not nil 
     self.printButton.layer.borderColor = [UIColor redColor].CGColor; 
     self.printButton.layer.borderWidth = 1.0; 

     [printController presentFromRect:self.printButton.bounds inView:self.printButton animated:YES 
      completionHandler:^(UIPrintInteractionController *aPrintController, BOOL aCompleted, NSError *anError) 
      { 
       NSLog(@"printing is done with error: %@", anError); 
      }]; 
    } 
} 

在iOS 9打印對話框顯示錯誤,不能被解僱攻外模式的看法沒有任何效果 - 應用程序變得反應遲鈍。

enter image description here

+0

我面臨與最新版本的iOS相同的問題。你能幫我解決嗎?你是如何修復它的? – spaleja

回答

1

發生了什麼事是取消&打印按鈕被模態窗口剪裁,讓你在該視圖中卡住。如果有人遇到類似問題,請檢查您是否在您的課堂上設置了固定寬度。一旦你更新了,按鈕應該回到模態。