2015-09-30 2 views
2

Depuis la mise à jour vers le dernier XCode/Swift 2/iOS 9, je reçois des avertissements lorsque j'essaie d'utiliser UIPrintInteractionController.AirPrint (UIPrintInteractionController) imprimer des avertissements avec iOS 9, swift 2, XCode 7

Ces avertissements SEULEMENT se produisent lorsque le "Print Simulator" est ouvert. Je pensais que c'était mon application, j'ai donc fait une nouvelle application vue unique avec un seul UIButton qui fait du code très simple et il génère toujours les avertissements. Cela se passe sur les simulateurs de téléphone et d'iPad.

Aidez-nous s'il vous plaît. Il me rend fou, Merci à tous

@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) 
    } 
} 

Voici les avertissements:

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. 
+0

vous ne réglaient jamais cela? J'ai exactement le même problème, et c'est extrêmement frustrant! – CodeNoob

Répondre

0

L'avertissement mentionné dans votre question est imprimé lorsqu'un élément est de taille dans un UICollectionView mal. Comme le message l'indique, un UICollectionViewCell ne peut pas être plus grand en hauteur que la somme de UICollectionView plus la section & inserts de contenu.

J'ai atteint votre question parce que j'ai rencontré le même avertissement et que je le cherchais. Dans mon cas, le code se présente comme suit:

func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize { 
     let height = self.collectionView.frame.height 
     let width = height * 0.75 
     return CGSizeMake(width, height) 
    } 

La ligne let height = self.collectionView.frame.height était à l'origine de l'avertissement pour moi. J'avais même changé les encarts à zéro mais jusqu'à ce que je raccourcie la taille en utilisant let height = self.collectionView.frame.height * 0.75 l'avertissement ne partait pas.

Vous ne savez pas si cela est pertinent car votre code n'affiche aucune information relative à UICollectionView et les encarts sont destinés au contrôleur d'impression. Cherchez-vous le bon endroit?

1

Probablement problème est avec

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

vérifier la vue rect pour presentFromRect

Ou bien essayer avec

[printController presentAnimated:YES completionHandler:nil]; 

Cette solution retiré des avertissements pour mon code, tentez votre chance.

0

eu le même problème, résolu en utilisant la méthode de délégué printInteractionControllerParentViewController(printInteractionController :)

Alors (Merci à Balooka!):

  1. Dans l'en-tête de classe:

    UIPrintInteractionControllerDelegate 
    
  2. Quelque part:

    let printController = UIPrintInteractionController.sharedPrintController() 
    
    printController.delegate = self 
    
  3. Mettre en oeuvre la fonction de délégué:

    func printInteractionControllerParentViewController(printInteractionController: UIPrintInteractionController) -> UIViewController { 
        return self 
    }