iOS 9 : UIPrintInteractionController presentation issue

标签 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

最佳答案

发生的事情是模式窗口剪裁了取消和打印按钮,使您停留在该 View 中。如果有人遇到类似问题,请检查您是否在 UINavigationBar 类上设置了固定宽度。更新后,按钮应返回模式。

关于iOS 9 : UIPrintInteractionController presentation issue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33690154/

相关文章:

iphone - iOS:Facebook 发布隐私

redirect - GDB 打印到文件而不是标准输出

html - 从 HTML 横向打印

iOS 9 - 重定向到通用链接不起作用

ios - 红蜘蛛:更新 pod 创建编译错误

iOS:UITableView cell.tag 数在进出 View 时不断增加

ios - 将数据保存到核心数据 - Swift

javascript - 使用 Zebra Technologies 打印机从 Web 应用程序打印

ios - Xcode 7 中的 "changing property masksToBounds in transform-only layer, will have no effect"

swift - 无法使用 'append' 类型的参数列表调用 '(String, Double)'