swift - AirPrint (UIPrintInteractionController) 使用 iOS 9、swift 2、XCode 7 打印警告

标签 swift ios9 airprint uiprintinteractioncntrler

自从更新到最新的 XCode/Swift 2/iOS 9 后,我在尝试使用 UIPrintInteractionController 时不断收到警告。

这些警告仅在我打开“打印模拟器”时出现。我以为这是我的应用程序,所以我用一个 UIButton 制作了一个新的单 View 应用程序,它执行非常简单的代码,但它仍然会生成警告。它发生在手机和 iPad 模拟器上

请帮忙。这让我疯狂, 谢谢大家

@IBAction func Clicked(sender: AnyObject) {

    let printController = UIPrintInteractionController.sharedPrintController()

    let printInfo = UIPrintInfo(dictionary:nil)
    printInfo.outputType = UIPrintInfoOutputType.General
    printInfo.jobName = "print Job"
    printController.printInfo = printInfo

    let formatter = UIMarkupTextPrintFormatter(markupText: "<b>Hello World</b>")
    formatter.contentInsets = UIEdgeInsets(top: 72, left: 72, bottom: 72, right: 72)
    printController.printFormatter = formatter

    if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
        printController.presentAnimated(false, completionHandler: nil)
    }else{
        printController.presentFromRect(view.frame, inView: view, animated: false, completionHandler: nil)
    }
}

警告如下:

2015-09-29 18:58:19.748 MyApp[1608:527574] Unbalanced calls to begin/end appearance transitions for <UIViewController: 0x13d5c6170>.
2015-09-29 18:58:20.013 MyApp[1608:527574] the behavior of the UICollectionViewFlowLayout is not defined because:
2015-09-29 18:58:20.014 MyApp[1608:527574] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
2015-09-29 18:58:20.015 MyApp[1608:527574] The relevant UICollectionViewFlowLayout instance is <UICollectionViewFlowLayout: 0x13d6a1e10>, and it is attached to <UICollectionView: 0x13e063c00; frame = (0 0; 320 250); clipsToBounds = YES; opaque = NO; autoresize = W+H; gestureRecognizers = <NSArray: 0x13d5e7ef0>; layer = <CALayer: 0x13d507850>; contentOffset: {0, 0}; contentSize: {0, 0}> collection view layout: <UICollectionViewFlowLayout: 0x13d6a1e10>.
2015-09-29 18:58:20.015 MyApp[1608:527574] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.
2015-09-29 18:58:20.026 MyApp[1608:527574] the behavior of the UICollectionViewFlowLayout is not defined because:
2015-09-29 18:58:20.026 MyApp[1608:527574] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
2015-09-29 18:58:20.027 MyApp[1608:527574] The relevant UICollectionViewFlowLayout instance is <UICollectionViewFlowLayout: 0x13d6a1e10>, and it is attached to <UICollectionView: 0x13e063c00; frame = (0 0; 320 250); clipsToBounds = YES; opaque = NO; autoresize = W+H; gestureRecognizers = <NSArray: 0x13d5e7ef0>; layer = <CALayer: 0x13d507850>; contentOffset: {0, 0}; contentSize: {320, 250}> collection view layout: <UICollectionViewFlowLayout: 0x13d6a1e10>.
2015-09-29 18:58:20.027 MyApp[1608:527574] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.
2015-09-29 18:58:21.735 MyApp[1608:527574] the behavior of the UICollectionViewFlowLayout is not defined because:
2015-09-29 18:58:21.735 MyApp[1608:527574] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
2015-09-29 18:58:21.736 MyApp[1608:527574] The relevant UICollectionViewFlowLayout instance is <UICollectionViewFlowLayout: 0x13d6ba990>, and it is attached to <UICollectionView: 0x13e02c400; frame = (0 0; 320 250); clipsToBounds = YES; opaque = NO; autoresize = W+H; gestureRecognizers = <NSArray: 0x13d6809a0>; layer = <CALayer: 0x13d6aa750>; contentOffset: {0, 0}; contentSize: {0, 0}> collection view layout: <UICollectionViewFlowLayout: 0x13d6ba990>.
2015-09-29 18:58:21.736 MyApp[1608:527574] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.
2015-09-29 18:58:21.758 MyApp[1608:527574] the behavior of the UICollectionViewFlowLayout is not defined because:
2015-09-29 18:58:21.759 MyApp[1608:527574] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
2015-09-29 18:58:21.759 MyApp[1608:527574] The relevant UICollectionViewFlowLayout instance is <UICollectionViewFlowLayout: 0x13d6ba990>, and it is attached to <UICollectionView: 0x13e02c400; frame = (0 0; 320 250); clipsToBounds = YES; opaque = NO; autoresize = W+H; gestureRecognizers = <NSArray: 0x13d6809a0>; layer = <CALayer: 0x13d6aa750>; contentOffset: {0, 0}; contentSize: {320, 250}> collection view layout: <UICollectionViewFlowLayout: 0x13d6ba990>.
2015-09-29 18:58:21.759 MyApp[1608:527574] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.

最佳答案

可能是

的问题
printController.presentFromRect(view.frame, inView: view, animated: false, completionHandler: nil)

验证 presentFromRect 的 View 矩形

否则试试

[printController presentAnimated:YES completionHandler:nil];

此解决方案删除了​​我的代码的警告,试试你的运气。

关于swift - AirPrint (UIPrintInteractionController) 使用 iOS 9、swift 2、XCode 7 打印警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32855724/

相关文章:

ios - Capabilities 下的 "Fix Issue"使我的配置文件无效。否则推不工作

ios - PrinterToPrint 不显示打印作业进度对话框

ios - PFQueryTableViewController 限制

swift 3 - !与?对于可选的函数参数

ios - 将 PHAsset 从 Gallery 复制到 iOS 9 中的其他目录

objective-c - PHPhotoLibrary 保存一个 gif 数据

ios - 自动 AirPrint IOS

ios - IPP 通过 HTTP : getting 400 bad request as a response

ios - ReactiveCocoa 4 : Observing an Action's completed event

ios - View 的自动布局相同的宽度和高度?