title: how to set dynamic uicollectionviewcell size from its content - programmatically
body: <p>I need to have just simple UICollectionViewCell style with cells on top of eachoher. Like tableview. But I need Dynamic height dependent of the content, size the content is comments it can vary.</p>
  
  <p>I got 
  viewDidLoad:</p>
  
  <pre><code>  [self.commentsCollectionView registerClass:[GWCommentsCollectionViewCell class] forCellWithReuseIdentifier:@"commentCell"];
  </code></pre>
  
  <p>in .h I got:
      </p>
  
  <p>and I #import my custom UICollectionViewCell that sets all constraints with programmatic autolayout.</p>
  
  <p>I instantiate the UICollectionView with:</p>
  
  <pre><code>UICollectionViewFlowLayout *collViewLayout = [[UICollectionViewFlowLayout alloc]init];
  self.commentsCollectionView = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:collViewLayout];
  </code></pre>
  
  <p>I use autolatyout to get the UICollectionView be where I want (thats why CGRectZero).</p>
  
  <p>And finally I was hoping to do this:</p>
  
  <pre><code>-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
  
      GWCommentsCollectionViewCell *cell = (GWCommentsCollectionViewCell*)[collectionView cellForItemAtIndexPath:indexPath];
  
      return cell.singleCommentContainerview.bounds.size;
  }
  </code></pre>
  
  <p>singleCommentContainerview is a direct subview of the contentView and withing the singleCommentContainerview I have UILabels, UIImageViews etc, all set witih autolayoutcode.</p>
  
  <p>But I just get cgsize value of (0,0)</p>
  
  <p>How can I fix this to get the proper size I need for each cell?</p>