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

How to implement sharing function in Android

[[169775]] I have become more and more lazy recen...

Price list for renting overseas server bandwidth configuration

The price list for renting overseas server bandwi...

Ramen says, the four-step traffic method behind explosive growth!

"In 2017, we started content marketing; in 2...

Microsoft withdraws first update of Windows 10 Mobile due to numerous bugs

[[159323]] Microsoft is already at a critical jun...

Summary of various bottlenecks encountered on the road of Android learning

[[197644]] Preface For most junior students, this...

How to place advertisements in Juliang Qianchuan live broadcast room

Juliang Qianchuan builds video or live broadcast ...

Content Marketing Trends in 2017 (Part 1)

Content Marketing Trends in 2017 (Part 2) Preface...