UICollectionView Autosize cell
<p>I have tableview cell collectionView inside each cell. In collectionView only images. There could be one or more 
If showing layout for 5 images it's ok. The issue when I am showing 1 image and need to resize collectionView according width and height of image. So I can show portrait images and landscape image. my current layout is </p>

<pre><code>func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -&gt; CGSize {

        switch images.count {
        case 1:
            let size = collectionView.frame.size.width
            return CGSizeMake(size, 250)
        default:
            let size = collectionView.frame.size.width / 5
            let offset = CGFloat(5)
            return CGSizeMake(size - offset, size - offset)
        }
    }
</code></pre>

<p>I am using default CollectionViewFlowLayout
Could you please help me with this issue?</p>