Row-based waterfall view

Row-based waterfall view

Source code introduction

The demo shows a row-based waterfall view, which only supports ARC mode.

Source code screenshot:

[[128131]]

Source code snippet:

  1. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  2. {
  3. BDRowInfo *ri = [_rowInfos objectAtIndex:indexPath.row];
  4. static NSString *CellIdentifier = @ "Cell" ;
  5. BDDynamicGridCell *cell = [tableView dequeueReusableCellWithIdentifier:[CellIdentifier stringByAppendingFormat:@ "_viewCount%d" , ri.viewsPerCell]];
  6.       
  7. if (!cell) {
  8. cell = [[BDDynamicGridCell alloc] initWithLayoutStyle:BDDynamicGridCellLayoutStyleFill
  9. reuseIdentifier:CellIdentifier];
  10.           
  11. cell.viewBorderWidth = 1 ;
  12.           
  13. UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action: @selector (didLongPress:)];
  14. longPress.numberOfTouchesRequired = 1 ;
  15. [cell.gridContainerView addGestureRecognizer:longPress];
  16.           
  17. UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action: @selector (didDoubleTap:)];
  18. doubleTap.numberOfTapsRequired = 2 ;
  19. doubleTap.delaysTouchesBegan = YES;
  20. [cell.gridContainerView addGestureRecognizer:doubleTap];
  21.           
  22. UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action: @selector (didSingleTap:)];
  23. singleTap.numberOfTapsRequired = 1 ;
  24. singleTap.delaysTouchesBegan = YES;
  25. [cell.gridContainerView addGestureRecognizer:singleTap];
  26. [singleTap requireGestureRecognizerToFail:doubleTap];
  27. }
  28.       
  29. //clear for updated list of views  
  30. [cell setViews:nil];
  31. cell.viewBorderWidth = self.borderWidth;
  32. cell.backgroundColor = nil;
  33.   
  34. cell.rowInfo = ri;
  35. NSArray * viewsForRow = [NSArray array];
  36. for ( int i= 0 ; i<ri.viewspercell; i++)= "" {= "" viewsforrow= "[viewsForRow" arraybyaddingobject:[self.delegate= "" viewatindex:i= "" += "" ri.accumulatedviews= "" rowinfo:ri]];= "" }= "" nsassert(viewsforrow.count= "" > 0 , @ "number of views per row must be greater than 0" );
  37. [cell setViews:viewsForRow];
  38.       
  39. return cell;
  40. }</ri.viewspercell;>

Source code link: http://download..com/data/1984619

<<:  How did WeChat product managers and architects handle 1 billion red envelopes?

>>:  Douban Photo Album Collection

Recommend

User operation, how to achieve a breakthrough from 0 to 1?

Users, as one of the most important factors in pr...

To do a good job in user operations, you need to start from these 6 aspects!

In the era of fan economy , the more users you ha...

A complete analysis of the Toutiao search account setup and delivery ideas

As a new search platform launched this year, Tout...

Methods and steps for planning and executing an event

Having worked in operations for several years, I ...

Charm Academy "Top Wealth Thinking"

Charm Academy "Top Wealth Thinking" Res...

A long article to talk about overseas mobile traffic advertising monetization

There are more and more Chinese mobile developers...

Event planning: How to design an excellent event format?

Whether we are individual entrepreneurs or event ...

What is QQ client advertising?

The number of monthly active QQ accounts reached ...