Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UICollectionView Layout Issue

I am using UICollectionView using the flow layout. I have made a custom UICollectionViewCell for the same. But on running the project the console keeps on throwing this error-

The behavior of the UICollectionViewFlowLayout is not defined because:  the item height must be less that the height of the UICollectionView minus the section insets top and bottom values. 

I have made sure that the size of the cell is correct

Has anyone been able to resolve this issue.

like image 834
Nitesh Avatar asked Apr 15 '13 10:04

Nitesh


People also ask

What is UICollectionView flow layout?

Overview. A flow layout is a type of collection view layout. Items in the collection view flow from one row or column (depending on the scrolling direction) to the next, with each row containing as many cells as will fit. Cells can be the same sizes or different sizes.

What is the difference between Uitableview and UICollectionView?

Tableiw is a simple list, which displays single-dimensional rows of data. It's smooth because of cell reuse and other magic. 2. UICollectionView is the model for displaying multidimensional data .

What is compositional layout?

A compositional layout is composed of one or more sections that break up the layout into distinct visual groupings. Each section is composed of groups of individual items, the smallest unit of data you want to present. A group might lay out its items in a horizontal row, a vertical column, or a custom arrangement.

When should I call Invalidatelayout?

You can call this method at any time to update the layout information. This method invalidates the layout of the collection view itself and returns right away. Thus, you can call this method multiple times from the same block of code without triggering multiple layout updates.


1 Answers

I found that, using storyboards, you have to go into the storyboard and click on the overall View Controller (the view should be highlighted in blue) and go to the Attributes Inspector (the fourth tab on the right side of the screen) and unchecking the "Under Top Bars", "Under Bottom Bars", and "Under Opaque Bars." This cleared up the issue for me, and it cleared it for my coworkers as well.

like image 196
Connor Wagner Avatar answered Sep 19 '22 18:09

Connor Wagner