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
35
votes
9 answers

UICollectionView estimatedItemSize - last cell is not aligned

I want to make a usual horizontalScrolling flowLayout UICollectionView with estimatedItemSize and preferredLayoutAttributesFittingAttributes in cell. But there is something wrong with last cell. Any idea where is the issue? Project…
artysx
  • 533
  • 5
  • 14
35
votes
7 answers

Where to highlight UICollectionViewCell: delegate or cell?

According to the Collection View Programming Guide one should handle the visual state of the cell highlights in the UICollectionViewDelegate. Like this: - (void)collectionView:(PSUICollectionView *)collectionView…
hpique
  • 119,096
  • 131
  • 338
  • 476
34
votes
2 answers

UICollection View Adjust Cell Size for Screen Size

Currently i have a collection view which takes up most of my screen at the 3.5 inch screen size.The collection view is 51 pixels from the top and 20 pixels from the bottom of the screen. I am using the cells with UIPageControl to create a paged…
34
votes
5 answers

UICollectionViewCell Border / Shadow

When building an iPad App, how can you draw a border around a UICollectionViewCell? More details: I implemented a class ProductCell which extends UICollectionViewCell. Now, I would like to assign some fancy details, e.g. a border, shadow, etc.…
itsame69
  • 1,540
  • 5
  • 17
  • 37
33
votes
3 answers

UICollectionView, simply fit cell to width?

Here's a simple UICollectionView in yellow The red arrow sets the width of the cell. (TBC: clicking on the pink cell: for 'size' select 'Default', then what you set at the red arrow becomes the size of the cell.) Example, for an upright iPhone set…
Fattie
  • 27,874
  • 70
  • 431
  • 719
33
votes
6 answers

Change Background of UICollectionView Cell on Tap

I have a UICollectionView that I have created programmatically. I would like for the collection view to behave in the following way: 1. User touches cell 2. Cell background color changes 3. User releases touch 4. Cell background color changes This…
33
votes
4 answers

How do I display the standard checkmark on a UICollectionViewCell?

I'm designing an iOS app with a UICollectionView, and I'd like users to be able to select multiple items within this view. It seems there's a standard style of checkmark Apple uses in this kind of situation. For example, in the image below you can…
Chris Vasselli
  • 13,064
  • 4
  • 46
  • 49
32
votes
6 answers

UICollectionViewCell subclass init never run

I have added a collection view in viewDidLoad like this... self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, 10, 10) collectionViewLayout:flowLayout]; self.collectionView.delegate = self; self.collectionView.dataSource =…
Fogmeister
  • 76,236
  • 42
  • 207
  • 306
31
votes
2 answers

UICollectionView registerClass: forCellWithReuseIdentifier method breaks UICollectionView

What's the role of registerClass:forCellWithReuseIdentifier: method? According to Apple's developer documentation it's supposed to "Register a class for use in creating new collection view cells." When I try to use it my project I get a black…
30
votes
6 answers

How can I customize the selection state of my UICollectionViewCell subclass?

I have a custom UICollectionViewCell subclass that overwrites initWithFrame: and layoutSubviews to setup its views. However, I'm now trying to do two things which I'm having trouble with. 1) I'm trying to customize the state of the…
user594161
29
votes
4 answers

Scrollbar incorrectly appears underneath UICollectionView section header

For some reason my scrollbar always appears underneath the collection view section header. Any help is greatly appreciated!
Soja
  • 514
  • 6
  • 13
29
votes
4 answers

Trying to override "selected" in UICollectionViewCell Swift for custom selection state

I am trying to implement a custom selection style for my cells in a UICollectionView. Even though it is easily possible to do this manually in the didSelect and didDeSelect methods I would like to achieve this by manipulating the "selected" variable…
Julius
  • 1,451
  • 1
  • 15
  • 19
29
votes
1 answer

Designing UICollectionView cells in nib with Interface Builder (without storyboard)

I am trying to design a custom UICollectionViewCell prototype (in Xcode 5.0.2), however Interface Builder doesn't let me add a cell to my UICollectionView while designing a nib. I can set the number of items (cells) and Interface Builder creates and…
28
votes
2 answers

UICollectionView cellForItemAtIndexPath is nil

I have a function that updates existing UICollectionView. The UICollectionView is created, I can see it, but when I want to access its cells to update it, they are nil. -(void)finishExam{ for (int i = 0; i < [self.questionsOverviewCollection…
Luda
  • 7,282
  • 12
  • 79
  • 139
28
votes
8 answers

How to select item in collectionview programmatically?

I have a UICollectionView. The UICollectionView's datasource is a NSArray of students (from CoreData). I want the current student item be selected/highlighted. How can I do this? I know there is a method: - (void)selectItemAtIndexPath:(NSIndexPath…
mrd
  • 4,561
  • 10
  • 54
  • 92