2015-11-13 58 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

发生了什么事是取消&打印按钮被模态窗口剪裁,让你在该视图中卡住。如果有人遇到类似问题,请检查您是否在您的课堂上设置了固定宽度。一旦你更新了,按钮应该回到模态。