the behavior of the UICollectionViewFlowLayout is not defined, because the cell width is greater than collectionView width

shouldinvalidatelayoutforboundschange
please check the values returned by the delegate.
uicollectionviewdelegateflowlayout
uicollectionview estimateditemsize

2015-08-18 16:07:51.523 Example[16070:269647] the behavior of the UICollectionViewFlowLayout is not defined because: 2015-08-18 16:07:51.523 Example[16070:269647] the item width must be less than the width of the UICollectionView minus the section insets left and right values, minus the content insets left and right values. 2015-08-18 16:07:51.524 Example[16070:269647] The relevant UICollectionViewFlowLayout instance is , and it is attached to ; animations = { position=; bounds.origin=; bounds.size=; }; layer = ; contentOffset: {0, 0}; contentSize: {1024, 770}> collection view layout: . 2015-08-18 16:07:51.524 Example[16070:269647] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.

This is what I get, what I do is

func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
        return CGSizeMake(self.collectionView!.frame.size.width - 20, 66)
    }

when I rotate from landscape to portrait, the console shows this error message only in iOS 9, does anyone know what this happens and if there is a fix for this?


This happens when your collection view resizes to something less wide (go from landscape to portrait mode, for example), and the cell becomes too large to fit.

Why is the cell becoming too large, as the collection view flow layout should be called and return a suitable size ?

collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath)

Update to include Swift 4

@objc override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
{  ...  }

This is because this function is not called, or at least not straight away.

What happens is that your collection view flow layout subclass does not override the shouldInvalidateLayoutForBoundsChange function, which returns false by default.

When this method returns false, the collection view first tries to go with the current cell size, detects a problem (which logs the warning) and then calls the flow layout to resize the cell.

This means 2 things :

1 - The warning in itself is not harmful

2 - You can get rid of it by simply overriding the shouldInvalidateLayoutForBoundsChange function to return true. In that case, the flow layout will always be called when the collection view bounds change.

The Behaviour Of the UICollectionViewFlowLayout is not defined , Hey there, I'm creating the calendar and cells programatically and I am getting this error: 2018-07-05 22:38:23.395310-0400 App[4517:269288] The behavior of the UICollectionViewFlowLayout is not defined because: the item width must be less than the width of the UICollectionView But it is more. the behavior of the UICollectionViewFlowLayout is not defined, because the cell width is greater than collectionView width 489 The resource could not be loaded because the App Transport Security policy requires the use of a secure connection


I've also seen this occur when we set the estimatedItemSize to automaticSize and the computed size of the cells is less than 50x50 (Note: This answer was valid at the time of iOS 12. Maybe later versions have it fixed).

i.e. if you are declaring support for self-sizing cells by setting the estimated item size to the automaticSize constant:

flowLayout.estimatedItemSize = UICollectionViewFlowLayout.automaticSize

and your cells are actually smaller than 50x50 points, then UIKit prints out these warnings. FWIW, the cells are eventually sized appropriately and the warnings seem to be harmless.

One fix workaround is to replace the constant with a 1x1 estimated item size:

flowLayout.estimatedItemSize = CGSize(width: 1, height: 1)

This does not impact the self-sizing support, because as the documentation for estimatedItemSize mentions:

Setting it to any other value causes the collection view to query each cell for its actual size using the cell’s preferredLayoutAttributesFitting(_:) method.

However, it might/might-not have performance implications.

Help With Collection View - iOS, The behavior of the UICollectionViewFlowLayout is not defined because: I have a collection view embedded in a collection view: And I'm just lost as how to figure out how to resolve this error message. I'm not sure how to get the width and set it appropriately. New replies are no longer allowed. the behavior of the UICollectionViewFlowLayout is not defined, because the cell width is greater than collectionView width 0 UICollectionView not fitting within view controller on certain Apple devices


I've solve this problem by using safeAreaLayoutGuide.

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {

    return CGSize(width: (view.safeAreaLayoutGuide.layoutFrame.width), height: 80);
}

and you also have to override this function to support portrait and landscape mode correctly.

 override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
    collectionView?.collectionViewLayout.invalidateLayout();
}

collectionView:layout:sizeForItemAtIndexPath, of the UICollectionViewFlowLayout is not defined, because the cell width is greater than collectionView width. shouldinvalidatelayoutforboundschange the behavior of the UICollectionViewFlowLayout is not defined because: the item height must be less than the height of the UICollectionView minus the section insets top and bottom values. I solved this issue by checking the values in section Insets.And for fix cell size I have used below code.


UICollectiionView Weirdness |Apple Developer Forums, Asks the delegate for the size of the specified item's cell. the flow layout uses the values in its itemSize property to set the size of items instead. the width of a single item must not exceed the width of the collection view (minus However, in the scrolling direction, items can be larger than the collection view because the  Does not work with collection view self-sizing cells (.estimatedItemSize) The behavior of the UICollectionViewFlowLayout is not defined because: 2016-10-19 10:14


Its happens because your collection view cell's width is bigger than collection view width after rotation.suppose that you have a 1024x768 screen and your collection view fills the screen.When your device is landscape,your cell's width will be self.collectionView.frame.size.width - 20 =1004 and its greater than your collection view's width in portrait = 768.The debugger says that "the item width must be less than the width of the UICollectionView minus the section insets left and right values, minus the content insets left and right values".

Swift: YouTube, I'm trying to gain more experience with Collection Views to replace a. All cell insets and such are defined as zero as to not contribute to the problem. The behavior of the UICollectionViewFlowLayout is not defined because: the item width must be less than the width of the UICollectionView minus the  The behavior of the UICollectionViewFlowLayout is not defined because the item width must be less than the width of the UICollectionView minus the section insets left and right values. Even though we set the constraints between the label and the cell that contains it, and the label multiline display is enabled, the collection view layout is not able to figure out yet the right height for the cell.


The behavior of the UICollectionViewFlowLayout is not defined , How to Render Vertical Video Cells in Horizontal Layout The behavior of the UICollectionViewFlowLayout is not defined because the During run-time, how can I delete the TrendingCell page and then add something else in its place? I mean the collection view in the menu bar. if there are 6 items inside, the width of​  The behavior of the UICollectionViewFlowLayout is not defined because: the item width must be less than the width of the UICollectionView minus the section insets left and right values, minus the content insets left and right values. Please check the values returned by the delegate.


Content Offsets and Crashing Collection Views -- D5K Thoughts, The behavior of the UICollectionViewFlowLayout is not defined because:, Programmer the item height must be less than the height of the UICollectionView minus the If you still force a height greater than o, you Will report the warning above the title. So the width and height of the UICollectionView should be set to be  2015-03-24 15:45:00.085 JSQMessages[98856:631617] the behavior of the UICollectionViewFlowLayout is not defined because: 2015-03-24 15:45:00.086 JSQMessages[98856:631617] the item width must be less than the width of the UICollectionView minus the section insets left and right values.


Can't get dynamically sized Collection View cells, Pretty simple - a collection view above another view (in this case in a UIStackView so we The behavior of the UICollectionViewFlowLayout is not defined because: accounted for when you calculate the height/width of your self sizing cell. to the content inset were greater than the collection view itself (​hence the crash)!  the behavior of the UICollectionViewFlowLayout is not defined because: the item width must be less than the width of the UICollectionView minus the section insets left and right values, minus the content insets left and right values. The relevant UICollectionViewFlowLayout instance is , and it is attached to .