Skip to content
This repository has been archived by the owner on May 15, 2020. It is now read-only.

Suggestions for using collectionViewLayout:sizeForItemAtIndexPath: #2

Open
Nemesisprime opened this issue Dec 18, 2015 · 0 comments
Open

Comments

@Nemesisprime
Copy link

At the moment, I'm using a static size cell, however, it'd be nice to actually size the cells to fit their content.

UAFilterableResultsController provides filteredObjectAtIndexPath to get items by their indexPath and it works in the other delegate calls, but not in this case.

func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
    let viewModel = self.searchResultsController.filteredObjectAtIndexPath(indexPath) as! Object
    let titleWidth = //...
    return CGSizeMake(titleWidth, 44)
}

It'll work on the initial go, but as soon as you attempt to filter the results, you'll get a crash. I know that's vague, but I haven't looked too deep into it yet.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant