Dynamic size UICollectionView cell

Sorry this is super late… But maybe this will help people who haven’t found an answer yet. If you have your images in an array, you can simply reference the image size and make the adjustments to the cell size from there: – (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { UIImage *image = [imageArray objectAtIndex:indexPath.row]; //You … Read more

Getting the screen location of a cell from a UICollectionView

-(void)collectionView:(UICollectionView *)cv didSelectItemAtIndexPath:(NSIndexPath *)indexPath; { UICollectionViewLayoutAttributes *attributes = [cv layoutAttributesForItemAtIndexPath:indexPath]; CGRect cellRect = attributes.frame; CGRect cellFrameInSuperview = [cv convertRect:cellRect toView:[cv superview]]; NSLog(@”%f”,cellFrameInSuperview.origin.x); } It work for me.You can try yourself

Could not cast value of type ‘UICollectionViewCell’

The template for a CollectionViewController in Xcode comes with this line of code in viewDidLoad, which changes the specification in your storyboard. // Register cell classes self.collectionView!.register(UICollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier) Simply delete that line. In older Swift versions the line is: // Register cell classes self.collectionView!.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier)

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

Like you did yourself, indexPathForItemAtPoint is a good way of finding the index path of the element you’re interested in. If your question is: how do i know the coordinates of this point? Then you should try with (using the same name you gave it in your code snippet): initialPinchPoint = CGPointMake(self.collectionView.center.x + self.collectionView.contentOffset.x, self.collectionView.center.y … Read more

UICollectionView’s cell disappearing

So, what did work? 1) Subclass UICollectionViewFlowLayout. 2) Set the flowLayout of my UICollectionView to my new subclass. 3) On the init method of the UICollectionViewFlowLayout subclass, set the orientation you want: self.scrollDirection = UICollectionViewScrollDirectionHorizontal; In my case it is Horizontal. 4) The important part: -(BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds { return YES; } At this moment, I should … Read more

How to change UICollectionViewCell size programmatically in Swift?

Make sure you conform to UICollectionViewDelegateFlowLayout for your class (for swift4) eg. class MyClass: UICollectionViewDelegateFlowLayout Prior to Swift 3 //Use for size func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize { } //Use for interspacing func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAtIndex section: Int) -> CGFloat { return 1.0 } func collectionView(collectionView: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)