title: crash while scrolling through the TableView which haves a Collectionview in it
body: <p>i was having this issue (<a href="https://stackoverflow.com/questions/32574881/uicollectionview-inside-of-uitableviewcell-autolayout">UICollectionView inside of UITableViewCell - AutoLayout</a>)</p>
  
  <p>and after trying several solution which are available in the internet i came with this <a href="https://stackoverflow.com/questions/24126708/uicollectionview-inside-a-uitableviewcell-dynamic-height">@Pablo Romeu's answer</a> i tried his solution , now i got a TableView with collectionView cells in it (which can dynamically change its size according to content in it)
   but when am scrolling through my tableview its getting crashed with this error :</p>
  
  <pre><code>    2016-06-13 22:05:51.546 WishMeluck[3507:425240] the behavior of the UICollectionViewFlowLayout is not defined because:
  2016-06-13 22:05:51.546 WishMeluck[3507:425240] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
  2016-06-13 22:05:51.546 WishMeluck[3507:425240] Please check the values return by the delegate.
  2016-06-13 22:05:51.547 WishMeluck[3507:425240] The relevant UICollectionViewFlowLayout instance is &lt;UICollectionViewFlowLayout: 0x7fb83c05de90&gt;, and it is attached to &lt;UICollectionView: 0x7fb83a0c7c00; frame = (0 82.5; 375 179); clipsToBounds = YES; autoresize = RM+BM; tag = 4; gestureRecognizers = &lt;NSArray: 0x7fb83c05cf00&gt;; layer = &lt;CALayer: 0x7fb83c055fb0&gt;; contentOffset: {0, 0}; contentSize: {539, 179}&gt; collection view layout: &lt;UICollectionViewFlowLayout: 0x7fb83c05de90&gt;.
  2016-06-13 22:05:51.547 WishMeluck[3507:425240] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.
  2016-06-13 22:05:51.548 WishMeluck[3507:425240] the behavior of the UICollectionViewFlowLayout is not defined because:
  2016-06-13 22:05:51.548 WishMeluck[3507:425240] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
  2016-06-13 22:05:51.548 WishMeluck[3507:425240] Please check the values return by the delegate.
  2016-06-13 22:05:51.548 WishMeluck[3507:425240] The relevant UICollectionViewFlowLayout instance is &lt;UICollectionViewFlowLayout: 0x7fb83c05de90&gt;, and it is attached to &lt;UICollectionView: 0x7fb83a0c7c00; frame = (0 82.5; 375 179); clipsToBounds = YES; autoresize = RM+BM; tag = 4; gestureRecognizers = &lt;NSArray: 0x7fb83c05cf00&gt;; layer = &lt;CALayer: 0x7fb83c055fb0&gt;; contentOffset: {0, 0}; contentSize: {539, 179}&gt; collection view layout: &lt;UICollectionViewFlowLayout: 0x7fb83c05de90&gt;.
  2016-06-13 22:05:51.548 WishMeluck[3507:425240] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.
  (lldb) 
  </code></pre>
  
  <p>am not able to figure out the cause of this error if any body knows then please help me out  </p>
  
  <p>added this codes to my TableViewCell </p>
  
  <pre><code>        override func awakeFromNib() {
          super.awakeFromNib()
          // Initialization code
  
  //        collectionViewContainer.frame = self.bounds;
  //        collectionViewContainer.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
  
          let flow: UICollectionViewFlowLayout = (self.collectionView.collectionViewLayout as! UICollectionViewFlowLayout)
          // Configure the collectionView
          flow.minimumInteritemSpacing = 1
              // This enables the magic of auto layout.
              // Setting estimatedItemSize different to CGSizeZero
              // on flow Layout enables auto layout for collectionView cells.
              // https://developer.apple.com/videos/play/wwdc2014-226/
              flow.estimatedItemSize = CGSizeMake(1, 1)
          // Disable the scroll on your collection view
          // to avoid running into multiple scroll issues.
          self.collectionView.scrollEnabled = true
      }
  
      func bindWithModel(model: AnyObject) {
          // Do your stuff here to configure the tableViewCell
          // Tell the cell to redraw its contentView
  
  
  
          self.contentView.layoutIfNeeded()
      }
  
      // THIS IS THE MOST IMPORTANT METHOD
      //
      // This method tells the auto layout
      // You cannot calculate the collectionView content size in any other place,
      // because you run into race condition issues.
      // NOTE: Works for iOS 8 or later
  
      override func systemLayoutSizeFittingSize(targetSize: CGSize, withHorizontalFittingPriority horizontalFittingPriority: UILayoutPriority, verticalFittingPriority: UILayoutPriority) -&gt; CGSize {
          // With autolayout enabled on collection view's cells we need to force a collection view relayout with the shown size (width)
  
  
          //self.collectionView.frame = CGRectMake(0, 0, targetSize.width, targetSize.height)
          self.collectionView.layoutIfNeeded()
          // If the cell's size has to be exactly the content
          // Size of the collection View, just return the
          // collectionViewLayout's collectionViewContentSize.
          return self.collectionView.collectionViewLayout.collectionViewContentSize()
      }
  </code></pre>
  
  <p>and this in my CollectionViewCell:</p>
  
  <pre><code>    class CollectionViewCell: UICollectionViewCell {
  
      @IBOutlet var imgView: UIImageView!
  
  
      override func awakeFromNib() {
  
          self.contentView.setNeedsLayout()
      }
  
  
  }
  </code></pre>
  
  <p>also this in my TableViewController:</p>
  
  <pre><code>    // Enable automatic row auto layout calculations
  self.tableView.rowHeight = UITableViewAutomaticDimension;
  // Set the estimatedRowHeight to a non-0 value to enable auto layout.
  self.tableView.estimatedRowHeight = 100
  </code></pre>
  
  <p>my project <a href="http://www.filetolink.com/bc0fe2eec4" rel="nofollow noreferrer">file</a></p>