uicollectionviewcell

UICollectionView estimatedItemSize - last cell is not aligned

别来无恙 提交于 2019-12-30 01:36:13
问题 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 itself @implementation RowCollectionView - (instancetype) initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout { if (self = [super initWithFrame:frame collectionViewLayout:layout]) { [self configureRowCollectionView]; } return self; } -

UICollectionView shows only the first item

試著忘記壹切 提交于 2019-12-29 09:38:10
问题 I'm working on a project similar to a video album. In that I'm using UICollectionView to display the thumb images of those videos. The worst part is that I should not use storyboard or xib files. I have tried to do this programatically. I'm currently working on this code: - (void)viewDidLoad { i = 0; UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; [layout setItemSize:CGSizeMake(self.view.frame.size.width/2.5,self.view.frame.size.width/2.5)]; collectionView = [

In a UICollectionView, the cells will not sit on the bottom

我怕爱的太早我们不能终老 提交于 2019-12-29 08:01:38
问题 Note it turned out it was a simple mistake the cells would not "sit on the bottom". However, it's an interesting question: "how to move the cells up and down." Below a brute force solution: writing your own flow layout. I was amazed that the only way to do it is entirely subclass UICollectionViewFlowLayout and write some tricky code in layoutAttributesForElementsInRect . It's possible this will help someone in the future, as there is very little example code for

Expandable UICollectionViewCell

对着背影说爱祢 提交于 2019-12-29 03:31:11
问题 I'm trying to program an expandable UICollectionViewCell. If the user presses the topbutton, the cell should expand to a different height and reveal the underlying content. My first implementation features a custom UICollectionViewCell, which can be expanded by clicking the topbutton, but the collectionview does not expand too. Atm. the cell is the last one in the collectionview and just by swiping down enough, you can see the expanded content. If you stop touching, the scrollview jumps up

UICellView cell layout in swift

爱⌒轻易说出口 提交于 2019-12-28 04:33:07
问题 I am trying to use a UICollectionView to create a grid which a user can set to be x cells by y cells (entered in text boxes), while still occupying the same width on the screen. I have been able to create a grid view which contains the correct number of cells, but these aren't in the correct layout yet, i.e. entering 5 by 7 will give 35 cells but not in a 5 cell by 7 cell layout. This is the code I have so far. MyCollectionViewCell.swift import UIKit class MyCollectionViewCell:

Set UICollectionViewCell width programmatically to UICollectionView width

偶尔善良 提交于 2019-12-26 03:47:00
问题 In the collection view how do we set the cell size of width and height based on the overall collection view. it will set for small to large devices (for example : if the collection view overall width = 375.0000 and we divide into 3. so it will set for the all the large and small devices). - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"SETTING SIZE FOR ITEM AT INDEX %d",

Using Custom Layout Causes collectionViewFlowLayout delegate function not being called

こ雲淡風輕ζ 提交于 2019-12-25 09:47:49
问题 I am using TRMosaicLayout to achieve a SnapChat like layout. However, after using it, I noticed that viewForSupplementaryElementOfKind is no longer called. Any thoughts? func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { print("THIS FUNCTION IS NO LONGER CALLED"); var view: UICollectionReusableView! = UICollectionReusableView(); switch kind { case UICollectionElementKindSectionFooter:

Removing a subview then adding it back

主宰稳场 提交于 2019-12-25 09:27:17
问题 I have a UICollectionViewCell with a gradient subview. In my view controller, I have buttons that are sorting CoreData and then reloadData() on the UICollectionView . To avoid my gradient subview to be drawn again and again (as it happened in the past), I implement removeFromSuperview() in prepareForReuse() . There I also implement a flag that keeps track of gradient existence so I still add a new gradient when cell is load. However after removing the gradient, my willMove(toSuperview: )

Dynamic UICollectionViewCell width with respect to frame width and aspect ratio

独自空忆成欢 提交于 2019-12-25 09:08:15
问题 This is a follow up question from UICollectionViewCell dynamic sizing for 4.4 and 5.5 inch While that solution is great, I'd like to generate a dynamic amount of item cells (kCellsPerRow) within the UIVIewController based on the device's width, aspect ratio, and amount of total items I have to display. I just can't figure out how to calculate the right amount of kCellsPerRow so that they are not too resized once they hit an aspect ratio limit. Here's what I have so far: var kCellsPerRow =

Check if cell completely displayed in collectionview

不羁的心 提交于 2019-12-25 04:09:05
问题 I have a collection view where the cell is of the size exactly to the collectionView, so each cell should occupy the whole screen. I have implemented a functionality where the cell is snapped to the complete view whenever it's dragged or decelerated through the scroll. This is how the UX works. https://drive.google.com/open?id=1v8-WxCQUzfu8V_k9zM1UCWsf_-Zz4dpr What I want: As you can see from the clip, the cell snaps to the whole screen. Now, I want to execute a method after it snaps. Not