UICollectionVIew: How can I remove the space on top first cell’s row?

UICollectionView is descendant of UIScrollView class which has contentInset property, setting -20 top inset fixes the problem [self.calendarView setContentInset:UIEdgeInsetsMake(-20, 0, 0, 0)]; However, the problem comes from UIViewController’s automaticallyAdjustsScrollViewInsets property. By documentation: Default value is YES, which allows the view controller to adjust its scroll view insets in response to the screen areas consumed by … Read more

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

How to create a centered UICollectionView like in Spotify’s Player

In order to create an horizontal carousel layout, you’ll have to subclass UICollectionViewFlowLayout then override targetContentOffset(forProposedContentOffset:withScrollingVelocity:), layoutAttributesForElements(in:) and shouldInvalidateLayout(forBoundsChange:). The following Swift 5 / iOS 12.2 complete code shows how to implement them. CollectionViewController.swift import UIKit class CollectionViewController: UICollectionViewController { let collectionDataSource = CollectionDataSource() let flowLayout = ZoomAndSnapFlowLayout() override func viewDidLoad() { super.viewDidLoad() title = … Read more

iOS 10 bug: UICollectionView received layout attributes for a cell with an index path that does not exist

This happened to me when number of cells in collectionView changed. Turns out I was missing invalidateLayout after calling reloadData. After adding it, I haven’t experienced any more crashes. Apple has made some modifications to collectionViews in iOS10. I guess that’s the reason why we are not experiencing same problem on older versions. Here’s my … Read more

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