title: UICollectionView with dynamic height not getting same space between cell
body: <p>I am having similar problem <a href="https://stackoverflow.com/questions/14482882/display-images-in-a-uicollectionview-how-to-achieve-fixed-vertical-spacing-bet">like this</a></p>
  
  <p>I am generating height of view at run time.Here is my code</p>
  
  <pre><code>@interface CollectionViewController ()
  {
      NSMutableArray *arrMain;
  }
  @property(nonatomic,strong) NSMutableArray *arrMain;
  @end
  
  @implementation CollectionViewController
  @synthesize arrMain,
  
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
  
      [cView registerNib:[UINib nibWithNibName:@"CViewCell" bundle:nil] forCellWithReuseIdentifier:kCellID];
  
      CViewFlowLayout *fl = [[CViewFlowLayout alloc] init];
      self.cView.collectionViewLayout = fl;
  
      NSString *strJson = MY FUNCTION WHICH RETURNS JSON STRING;
      SBJSON *parser = [[SBJSON alloc] init];
  
      self.arrMain = [[NSMutableArray alloc] init];
      self.arrMain = [parser objectWithString:strJson error:nil];
      for (int i=0; i&lt;[self.arrMain count]; i++) {
          NSDictionary *dic = [self.arrMain objectAtIndex:i];
          [self setTags:[[UIView alloc] init] selDictionary:dic];  // This function generates height and save it to the dictionary
      }
      [cView reloadData];
  }
  
  - (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section;
  {
      return [self.arrMain count];
  }
  - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
  {
  
      NSDictionary *dic = [self.arrMain objectAtIndex:indexPath.row];
      return CGSizeMake(236,40+[[dic valueForKey:@"TAGS_HEIGHT"] intValue]);
  }
  - (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath;
  {
  
      CViewCell *cell =(CViewCell *) [cv dequeueReusableCellWithReuseIdentifier:kCellID forIndexPath:indexPath];
      NSDictionary *dic = [self.arrMain objectAtIndex:indexPath.row];
      if ([cell viewWithTag:11]){
          [[cell viewWithTag:11] release];
          [[cell viewWithTag:11] removeFromSuperview];
      }
      UIView *viewTags = [[UIView alloc] init];
      [viewTags setTag:11];
      [viewTags setBackgroundColor:[UIColor lightGrayColor]];
      [self setTags:viewTags selDictionary:dic];
      [viewTags setFrame:CGRectMake(5, 10, CONTENT_WIDTH, [[dic valueForKey:@"TAGS_HEIGHT"] floatValue])];
      [cell.contentView addSubview:viewTags];
  
      return cell;
  }
  </code></pre>
  
  <p>I had tried above link solution but it is not working for me.
  Here is an image of my output.</p>
  
  <p><img src="https://i.stack.imgur.com/ywHPz.png" alt=""> </p>
  
  <p>I need the spacing to be same. 
  Is anyone having solution for this issue ?</p>
  
  <p>Is this bug of UICOllectionView ? Because I found this issue in <a href="http://www.raywenderlich.com/22417/beginning-uicollectionview-in-ios-6-part-22" rel="nofollow noreferrer">this article</a> also.</p>