gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 01:38:49 45 4
gpt4 key购买 nike

自从更新到最新的 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/

45 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com