Questions tagged [uicollectionviewcell]

UICollectionViewCell is a class from UIKit framework in iOS. A UICollectionViewCell object presents the content for a single data item when that item is within the collection view’s visible bounds. Available in iOS 6.0 and later which is inherited from `NSObject->UIResponder->UIView->UICollectionReusableView->UICollectionViewCell`

Cells present the main content of a collection view. The job of a cell is to present the content for a single item from the data source object. Each cell must be an instance of the UICollectionViewCell class, which you may subclass as needed to present your content. Cell objects provide inherent support for managing their own selection and highlight state, although some custom code must be written to actually apply a highlight to a cell. A UICollectionViewCell object is a specific type of reusable view that might be used for main data items.

To configure the appearance of your cell, add the views needed to present the data item’s content as subviews to the view in the contentView property.

Resource

Questions

4470 questions
237
votes
18 answers

UICollectionView Self Sizing Cells with Auto Layout

I'm trying to get self sizing UICollectionViewCells working with Auto Layout, but I can't seem to get the cells to size themselves to the content. I'm having trouble understanding how the cell's size is updated from the contents of what's inside the…
rawbee
  • 2,946
  • 3
  • 18
  • 22
162
votes
11 answers

How to set cell spacing and UICollectionView - UICollectionViewFlowLayout size ratio?

I'm trying to add UICollectionView to ViewController, and I need to have 3 cells 'per row' without blank space between cells (it should look like a grid). Cell width should be one third of screen size, so I thought that the layout.item width should…
161
votes
12 answers

Autoresizing issue of UICollectionViewCell contentView's frame in Storyboard prototype cell (Xcode 6, iOS 8 SDK) happens when running on iOS 7 only

I'm using Xcode 6 Beta 3, iOS 8 SDK. Build Target iOS 7.0 using Swift. Please refer to my problem step by step with screenshots below. I have a UICollectionView in Storyboard. 1 Prototype UICollectionViewCell which contains 1 label in the centre (no…
thkeen
  • 1,857
  • 2
  • 13
  • 16
156
votes
8 answers

Why is UICollectionViewCell's outlet nil?

I have created a custom UICollectionViewCell in Interface Builder, binded views on it to the class, and then when I want to use and set a string to the label on the string, tha label has a nil value. override func viewDidLoad() { …
János
  • 32,867
  • 38
  • 193
  • 353
123
votes
17 answers

Adding rounded corner and drop shadow to UICollectionViewCell

So I already went through various posts on adding 2nd view for adding shadow, but I still cannot get it to work if I want to add it in UICollectionViewCell. I subclassed UICollectionViewCell, and here is my code where I add various UI elements to…
Vincent Yiu
  • 1,291
  • 2
  • 11
  • 14
121
votes
11 answers

Dynamic cell width of UICollectionView depending on label width

I have a UICollectionView, that loads cells from reusable cell, which contains label. An array provides content for that label. I can resize label width depending on content width easily with sizeToFit. But I cannot make cell to fit label. Here's…
pulp
  • 1,768
  • 2
  • 16
  • 24
115
votes
17 answers

UICollectionView Set number of columns

I just started learning about UICollectionViews. I'm wondering if anyone knows how to specify the number of columns in a collectionview. The default is set to 3 (iPhone/portrait). I've looked at the documentation and can't seem to find a concise…
SNV7
  • 2,563
  • 5
  • 25
  • 37
100
votes
6 answers

Change UICollectionViewCell size on different device orientations

I am using an UICollectionView with UICollectionViewFlowLayout. I set the size of each cell through the collectionView:layout:sizeForItemAtIndexPath: When switching from portrait to landscape, I would like to adjust the size of each cell to…
Fmessina
  • 3,751
  • 3
  • 31
  • 34
87
votes
24 answers

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

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…
79
votes
12 answers

UICollectionView flowLayout not wrapping cells correctly

I have a UICollectionView with a FLowLayout. It will work as I expect most of the time, but every now and then one of the cells does not wrap properly. For example, the the cell that should be on in the first "column" of the third row if actually…
lindon fox
  • 3,298
  • 3
  • 33
  • 59
71
votes
3 answers

UICollectionView adding UICollectionCell

When I try to put UICollectionCell to UICollectionView in Interface Builder I can't put it with unknown reasons. The cell is going to the tools bar without adding to UICollectionView I am using: iOS SDK 6.0 XCode 4.5.1 I don't use Storyboard
Matrosov Oleksandr
  • 25,505
  • 44
  • 151
  • 277
69
votes
9 answers

How to change UICollectionViewCell size programmatically in Swift?

I have a UICollectionView with a segmented control to switch between data. But how do I change the UICollectionViewCell size properties programmatically ? then I can custom each style appropriately for each data type. For example change the width…
RileyDev
  • 2,950
  • 3
  • 26
  • 61
61
votes
11 answers

how to get indexPath for cell which is located in the center of UICollectionView

How can i find indexPath for cell in the middle of UICollectionView? I have horizontal scrolling and only one big cell is visible (partially two other cells on the sides are visible as well). I need to delete cell located in the center (means -…
Sasha Prent
  • 1,151
  • 2
  • 10
  • 11
61
votes
12 answers

UICollectionView's cell disappearing

What's happening Currently I have an application that uses two UICollectionViews inside a UITableView. This way I create a Pulse News look like application. My problem with this is that sometimes the 6th and 11th row disappears completely, leaving a…
Rui Peres
  • 25,741
  • 9
  • 87
  • 137
57
votes
6 answers

Could not cast value of type 'UICollectionViewCell'

I use a custom CollectionViewCell in my Storyboard. When I start the app I get this message: Could not cast value of type 'UICollectionViewCell' to TestProject.CollectionViewCell.
coco
  • 4,912
  • 2
  • 25
  • 33
1
2 3
99 100