iOS 9:UIPrintInteractionController演示文稿问题

时间:2015-11-13 10:04:32

标签: ios printing ios9

我在这个非常奇怪的问题上挣扎了好几天。这是初始化和呈现打印对话框的标准代码,在iOS 9之前完全正常工作:

- (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

1 个答案:

答案 0 :(得分:1)

正在发生的事情是取消&模态窗口正在剪切打印按钮,使您卡在该视图中。如果有人遇到类似问题,请检查您是否在UINavigationBar课程中设置了固定宽度。更新后,按钮应该返回模态。