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
27
votes
4 answers

Perform a segue programmatically

Hi I'm trying to perform a segue programmatically without the Storyboard. Currently I have this as my code: override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if segue.identifier == "popOutNoteExpanded" { let vc =…
ajayb
  • 633
  • 1
  • 9
  • 23
27
votes
6 answers

Adding padding to first and last cell of UICollectionView

I have subclassed UICollectionViewFlowLayout to get horizontal UICollectionView with paging like behavior. It works perfectly fine as long as UICollectionViewCell is not first of last cell. Images attached below. Do I need to override something…
27
votes
3 answers

Display just two columns, with multiple rows in a CollectionView using storyboard

I want to display only two cells in a row, no matter what the iPhone screen size is. Like, My storyboard contains a UICollectionView,connected by constraints. The storyboard settings for the UICollectionView is, Now, when I run this in 6, 5s or…
rajesh s
  • 347
  • 1
  • 5
  • 12
27
votes
2 answers

UICollectionView animations (insert/delete items)

I'd like to customize the animation styles when a UICollectionViewCell is inserted and/or deleted. The reason why I need this is that by default I see that inserting a cell has a smooth fade in animation, however deleting a cell has a combination…
26
votes
3 answers

Reloading a UICollectionView using reloadData method returns immediately before reloading data

I need to know when reloading a UICollectionView has completed in order to configure cells afterwards (because I am not the data source for the cells - other wise would have done it already...) I've tried code such as [self.collectionView…
25
votes
8 answers

How to change space between cells in UICollectionView?

I want to reduce the size between cells in row. Now it looks like: I'm trying this, for reduce the size between them: let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout() layout.sectionInset = UIEdgeInsets(top: 20, left: 2,…
John Doe
  • 811
  • 4
  • 14
  • 26
25
votes
10 answers

pre select/highlight UICollectionViewCell on first load of view

Im trying to preselect the first object/UICollectionViewCell in the UICollectionView? I have tried: self.dateCollectionView.allowsMultipleSelection=NO; [self.dateCollectionView selectItemAtIndexPath:0 animated:YES…
DevC
  • 6,982
  • 9
  • 45
  • 80
24
votes
7 answers

How do I use UILongPressGestureRecognizer with a UICollectionViewCell in Swift?

I would like to figure out how to println the indexPath of a UICollectionViewCell when I long press on a cell. How can I do that in Swift? I have looked all over for an example of how to do this; can't find one in Swift.
webmagnets
  • 2,266
  • 3
  • 33
  • 60
24
votes
6 answers

UIImageView in custom UICollectionViewCell returning nil all the time

OK in my story board I have made a UICollectionView with 3 cells. One of the cells I made a custom class for that obviously extends the UICollectionViewCell: And I registered the class in my ViewDiDApear: [self.collectionView…
user1001506
24
votes
4 answers

Different cell size in UICollectionview

In my iphone app,I am showing images on a collection view. I fetch the images from urls,with urls I get the image size also. eg:- let's say there are two kinds of images landscape and portrait.I get value P for portrait images and L for landscape…
New Jango Tester
  • 561
  • 3
  • 5
  • 10
24
votes
4 answers

How to add views between UICollectionViewCells in a UICollectionView?

I'm trying to add UIViews between my UICollectionViewCells in my UICollectionView and I don't know how I could do that. I'm trying to accomplish something like this: I'll probably need to write a custom UICollectionViewLayout, but I don't really…
23
votes
1 answer

Getting loaded vs visible cells on a UITableView or UICollectionView

With the introduction of iOS 10, it seems like we're going to have prefetching enabled by default on UITableView and UICollectionViews. This means that cells that aren't displayed on the screen are going to be fetched before the user actually sees…
Senseful
  • 86,719
  • 67
  • 308
  • 465
23
votes
7 answers

How to delete an item from UICollectionView with indexpath.row

I have a collection view,and I tried to delete a cell from collection view on didSelect method.I succeeded in that using the following method [colleVIew deleteItemsAtIndexPaths:[NSArray arrayWithObject:indexPath]]; But now I need to delete the…
user2000452
23
votes
8 answers

UICollectionViewCells not appearing in a UICollectionView

As the title suggests I have a UICollectionView that is hooked up to a UIViewController through IB. I have a UICollectionView subclass called imageCell. In the viewcontroller viewDidLoad method, I register the class like this: CGRect…
virindh
  • 3,775
  • 3
  • 24
  • 49
23
votes
7 answers

Getting button action : UICollectionView Cell

I have created a UICollectionViewCell by nib and added a button inside it and created a .h and .m files added the class to the nibs file's owner.then wrote a button action in the .m connected it via outlet. The collection view is populating fine…
Lithu T.V
  • 19,955
  • 12
  • 56
  • 101