Removing empty space, if the section header is hidden in the UICollectionView

At last, I found an answer for my question. I have missed something. Anyway sorry for other fellow users. I set the header height and width inside the below method till now as @san said. – (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath But It is not the correct method to set the frame size … Read more

UICollectionView cell subviews do not resize

I ran into the same issue just now. When using the UICollectionViewFlowLayoutDelegate method to set the cell size depending on device and device-orientation, the size would be calculated properly but subviews would not resize to fill the newly size cell. The effect was a large blank cell with small subviews that don’t fill the cell’s … Read more

Reload UICollectionView header or footer?

You can also use (the lazy way) collectionView.collectionViewLayout.invalidateLayout() // swift [[_collectionView collectionViewLayout] invalidateLayout] // objc More complex would be to provide a context collectionView.collectionViewLayout.invalidateLayout(with: context) // swift [[_collectionView collectionViewLayout] invalidateLayoutWithContext:context] // objc You can then make a or configure the context yourself to inform about what should be updated see: UICollectionViewLayoutInvalidationContext It has a function … Read more

Add a simple UIView as header of UICollectionView

In swift like below Register Header View collectionView.register(HeaderView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: “headerView”) In UICollectionViewDataSource func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView { let headerView = collectionView.dequeueReusableSupplementaryViewOfKind(UICollectionElementKindSectionHeader, withReuseIdentifier: “headerView”, forIndexPath: indexPath) headerView.frame.size.height = 100 return headerView } Important is that you are supply the flow layout with the header size flowLayout.headerReferenceSize = … Read more

How can I check if an indexPath is valid, thus avoiding an “attempt to scroll to invalid index path” error?

You could check – numberOfSections – numberOfItemsInSection: of your UICollection​View​Data​Source to see if your indexPath is a valid one. E.g. extension UICollectionView { func isValid(indexPath: IndexPath) -> Bool { guard indexPath.section < numberOfSections, indexPath.row < numberOfItems(inSection: indexPath.section) else { return false } return true } }

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