Where to highlight UICollectionViewCell: delegate or cell?

As the documentation says, you can rely on highlighted property to be changed while the cell is highlighted. For example the following code will make the cell red when highlighted (not its subviews though): – (void)setHighlighted:(BOOL)highlighted { [super setHighlighted:highlighted]; [self setNeedsDisplay]; } – (void)drawRect:(CGRect)rect { [super drawRect:rect]; if (self.highlighted) { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetRGBFillColor(context, … Read more

How can I enable/disable section headers in UICollectionView programmatically?

You can either use the collectionView:layout:referenceSizeForHeaderInSection: method of the UICollectionViewDelegateFlowLayout and return CGSizeMake(0,0) or set accordingly the headerReferenceSize of UICollectionViewFlowLayout. Edit: headerReferenceSize is actually the property that storyboard uses to show/hide the headers. I’ve added the relevant lines from the Storyboard file With section checkbox on: <collectionViewFlowLayout key=”collectionViewLayout” minimumLineSpacing=”10″ minimumInteritemSpacing=”10″ id=”xAt-Uo-bMl”> <size key=”headerReferenceSize” width=”50″ height=”50″/></collectionViewFlowLayout> … Read more

Subview frame is incorrect when creating UICollectionViewCell

You can get the final frames of your cell by overriding layoutIfNeeded() in your custom Cell class like this: override func layoutIfNeeded() { super.layoutIfNeeded() self.subView.layer.cornerRadius = self.subView.bounds.width / 2 } then in your UICollectionView data Source method cellForRowAtIndexPath: do this: let cell = collectionView.dequeueReusableCellWithReuseIdentifier(“Cell”, forIndexPath: indexPath) as! CustomCollectionViewCell cell.setNeedsLayout() cell.layoutIfNeeded()

How to create UICollectionViewCell programmatically

Try to copy and paste this code into your xcode, it should work // // HomeVIewController.swift // Photolancer // // Created by Lee SangJoon on 9/8/16. // Copyright © 2016 Givnite. All rights reserved. // import UIKit class HomeViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout { var collectionview: UICollectionView! var cellId = “Cell” override func viewDidLoad() { super.viewDidLoad() … Read more

Resize UICollectionView cells after their data has been set

I think your are looking for the invalidateLayout method you can call on the .collectionViewLayout property of your UICollectionView. This method regenerates your layout, which in your case means also calling -collectionView: layout: sizeForItemAtIndexPath:, which is the right place to reflect your desired item size. Jirune points the right direction on how to calculate them. … Read more

Auto Layout in UICollectionViewCell not working

Well, I just looked on the iOS developer forums. Apparently, this is a bug with the iOS 8 SDK running on iOS 7 devices. The workaround is to add the following to your subclass of UICollectionViewCell: – (void)setBounds:(CGRect)bounds { [super setBounds:bounds]; self.contentView.frame = bounds; } override var bounds: CGRect { didSet { contentView.frame = bounds … Read more

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