Reputation: 271
Since updating to the newest XCode/Swift 2/iOS 9 I keep getting warnings when trying to use UIPrintInteractionController.
These warnings ONLY happen when I have the "Print Simulator" open. I thought it was my app so I made a new single view app with a single UIButton that does very simple code and it still generates the warnings. It happens on both the phone and iPad simulators
Please help. It's driving me crazy, Thank You All
@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)
}
}
Here are the warnings:
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.
Upvotes: 2
Views: 1447
Reputation: 11
Had the same problem, solved by using the delegate method printInteractionControllerParentViewController(printInteractionController
:)
(Thanks to Balooka!)
So:
In the class header:
UIPrintInteractionControllerDelegate
Somewhere:
let printController = UIPrintInteractionController.sharedPrintController()
printController.delegate = self
Implement the delegate function:
func printInteractionControllerParentViewController(printInteractionController: UIPrintInteractionController) -> UIViewController {
return self
}
Upvotes: 1
Reputation: 197
Probably issue is with
printController.presentFromRect(view.frame, inView: view, animated: false, completionHandler: nil)
verify the view rect for presentFromRect
Or else Try with
[printController presentAnimated:YES completionHandler:nil];
This solution removed warnings for my code, try your luck.
Upvotes: 1
Reputation: 121
The warning mentioned in your question is printed when an item is sized within a UICollectionView
incorrectly. As the message states, a UICollectionViewCell
cannot be taller in height than the sum of UICollectionView
plus section & content insets.
I reached your question because I ran into the same warning and was searching for it. In my case the code looked as follows:
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)
}
The line let height = self.collectionView.frame.height
was causing the warning for me. I had even changed the insets to zero but until I shortened the height using let height = self.collectionView.frame.height * 0.75
the warning did not go away.
Not sure if this is relevant as your code does not show any UICollectionView related information, and the insets are for print controller. Are you looking at the right place?
Upvotes: -1