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

Frequency band division of wireless technology for the Internet of Things

Wireless communication technologies all need cert...

4 major pitfalls of short video operations in the education industry

In 2020, if large, medium and small enterprises d...

Private domain marketing plan for the medical beauty industry!

In this age where looks matter, appearance anxiet...

6 key points for event planning and promotion!

How to create an event that will go viral on WeCh...

A rough and fast Android full-screen adaptation solution

1. Current situation Due to the serious fragmenta...

Case analysis: How to build a user incentive system?

The construction of a user incentive system is ge...

Why can ordinary H5 games make users unable to stop playing?

When it comes to games , what comes to everyone’s...

IBM cognitive white paper: The path to intelligence

When the term artificial intelligence was first c...