I have collectionView
with images in each cell.
I want to see the full image when tapping on a cell.
I know this can be done with the selectItemAtIndexPath
method and that I need to do something with the selected Cell:
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath)
{
println("Row: \(indexPath.row) is selected")
var cell:UICollectionViewCell = collectionView.cellForItemAtIndexPath(indexPath)!
}
I've seen a lot of code examples in objc, like here, but I can't figure it out in Swift.
Thank you in advance
Update:
My code so far:
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath)
{
collectionView.collectionViewLayout.invalidateLayout()
let cell = collectionView.cellForItemAtIndexPath(indexPath)
let animateChangeWidth = { [weak cell] in
let frame:CGRect = cell.frame
frame.size = cell.intrinsicContentSize()
cell.frame = frame
}
UIView.transitionWithView(cell, duration: 0.7, options: UIViewAnimationOptions.CurveLinear, animations: animateChangeWidth, completion: nil)
}
the error I'm getting is in the start of the block line:
Cannot convert the expression's type '() -> () -> $T0' to type '() -> () -> $T0'
I think it still has something to do with defining the (weak) cell.