uicollectionviewcell

Swift 3: How to center horizontally the last row of cells in a UICollectionView with only one section?

混江龙づ霸主 提交于 2019-12-01 06:47:36
I'm using a UICollectionView with only one section. Here's some visualization: [ x x x ] [ x x x ] [ x x ] If the last row in the UICollectionView does not have all 3 cells filled, I'd like to center those cells like so: [ x x x ] [ x x x ] [ x x ] I've tried to implement solutions from the following places: How to center horizontally UICollectionView Cells? How to center align the cells of a UICollectionView? However, the solutions shifts all the cells, and I'd like to only shift the LAST row if that last row doesn't contain X number of cells since I only have one section. I know how to set

UICollectionView recieved layout attributes for a cell with an index path that does not exist

萝らか妹 提交于 2019-12-01 06:46:15
问题 I have used UICollection view to show items in grid layout. For data source I have use 5*5 dimensional array. And also I am returning 5 for numberOfItems in section and 5 for numberOfSections. Then also my app is getting crashed with following error: 'UICollectionView recieved layout attributes for a cell with an index path that does not exist: {length = 2, path = 0 - 5}' //////===viewcontroller.m==/////// - (void)viewDidLoad { self.theData = @[@[@"1",@"2",@"3",@"4",@"5"], @[@"6",@"7",@"8",@

Add Facebook Shimmer on multiple UIViews

主宰稳场 提交于 2019-12-01 06:21:59
问题 I am trying to add Facebook Shimmer on UICollectionViewCell which has multiple UIViews. For one UIView , it's working fine with below code: let shimmeringView = FBShimmeringView(frame: imageView.frame) shimmeringView.contentView = imageView backgroundView.addSubview(shimmeringView) shimmeringView.isShimmering = true Where backgroundView is the view in which I have all the subviews such as imageView , labelView and others. While I am trying to add multiple views then first view is getting

UICollectionView - order cells horizontally

谁说胖子不能爱 提交于 2019-12-01 04:18:45
问题 So basically my problem is that my uicollectionview's cells are ordered from top to bottom, rather than from left to right. This is what it looks like - [1][4][7] [2][5][8] [3][6][9] This is what i want - [1][2][3] [4][5][6] [7][8][9] Another problem is when i scroll horizontally instead of moving the page a full 320points. It only moves enough to fit the next cell in the view. this is what it looks like - [2][3][10] [5][6][ ] [8][9][ ] this is what i want - [10][ ][ ] [ ][ ][ ] [ ][ ][ ] I

UICollectionView moveItemAtIndexPath:toIndexPath: issues moving items not on screen

二次信任 提交于 2019-12-01 03:58:21
I'm trying to animate a re-sort of items in UICollectionView on iOS 6. I wrote this code: NSMutableDictionary *from = [NSMutableDictionary dictionaryWithCapacity:self.count]; for (int ii = 0; ii < self.count; ii++) { MyItem item = [self getItemAtIndex:(NSInteger)ii]; [from setObject:[NSNumber numberWithInt:ii] forKey:[NSNumber numberWithInt:item.id]]; } [self sort]; [self.collectionView performBatchUpdates:^{ for (int ii = 0; ii < self.count; ii++) { MyItem item = [self getItemAtIndex:(NSInteger)ii]; NSNumber *prevPos = (NSNumber *)[from objectForKey:[NSNumber numberWithInt:item.id]]; if (

Setting corner radius on a cell kills UICollectionView's performance

∥☆過路亽.° 提交于 2019-12-01 03:24:39
I have a UICollectionView that has only a few cells (about 20). Performance for this collection works great. However, as soon as I try to round the corners of the UICollectionViewCells that are being rendered by this view, my performance takes a significant hit. In my cell's init method, this is the only line I add to cause this: [self.layer setCornerRadius:15]; Since this is in the init method and I am reusing the cells properly, I don't see why this should be causing me issue. I have tried adjusting the rasterization and opacity of the sell using multiple combinations of the following, with

Swift - could not dequeue a view of kind: UICollectionElementKindCell with identifier

大城市里の小女人 提交于 2019-12-01 03:21:05
I got this error message when trying to load UICollectionView. 2015-07-23 16:16:09.754 XXXXX[24780:465607] Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier CollectionViewCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard' First throw call stack: My code @IBOutlet var collectionView: UICollectionView! func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { let

Using a UICollectionView from a UICollectionViewCell

不打扰是莪最后的温柔 提交于 2019-12-01 03:09:08
问题 I have a custom UICollectionViewCell whose content is also a collection and I would like to use UICollectionView to display its content. Is this possible? How would I accomplish this? I made the custom UICollectionViewCell also inheriting from UICollectionViewDataSource and define a UICollectionView internal property but things are not working as expected. Any idea? 回答1: This is possible. Typically you would create a view controller which manages the inner collection view, and add the view of

How to set UILabel on UICollectionViewCell?

ⅰ亾dé卋堺 提交于 2019-12-01 01:20:47
I've done this several dozen times with custom and standard UITableView cells. All my outlets are connected. The UILabel is a subview of my UICollectionViewCell in IB. My UICollectionViewCell object inherits the proper class in identity inspector. How do I set UILabel on UICollectionViewCell ? MyCell.m -(void)setCellName:(NSString *)cellName { self.cellLabel.text = cellName; } ViewController.m - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { ADMCell *cell = (ADMCell *)[collectionView

UICollectionView moveItemAtIndexPath:toIndexPath: issues moving items not on screen

人走茶凉 提交于 2019-12-01 00:49:14
问题 I'm trying to animate a re-sort of items in UICollectionView on iOS 6. I wrote this code: NSMutableDictionary *from = [NSMutableDictionary dictionaryWithCapacity:self.count]; for (int ii = 0; ii < self.count; ii++) { MyItem item = [self getItemAtIndex:(NSInteger)ii]; [from setObject:[NSNumber numberWithInt:ii] forKey:[NSNumber numberWithInt:item.id]]; } [self sort]; [self.collectionView performBatchUpdates:^{ for (int ii = 0; ii < self.count; ii++) { MyItem item = [self getItemAtIndex: