Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added the support to identify a cell and reuse it with a specific ide…

…ntifier.
  • Loading branch information...
commit a27c51c7ddeaecd5f19c9096007ec6cd3a4fd5f2 1 parent 631774c
Jean-Philippe Couture jcouture authored
1  GMGridView/GMGridView.h
@@ -91,6 +91,7 @@ typedef enum
91 91
92 92 // Reusable cells
93 93 - (GMGridViewCell *)dequeueReusableCell; // Should be called in GMGridView:cellForItemAtIndex: to reuse a cell
  94 +- (GMGridViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier;
94 95
95 96 // Cells
96 97 - (GMGridViewCell *)cellForItemAtIndex:(NSInteger)position; // Might return nil if cell not loaded for the specific index
12 GMGridView/GMGridView.m
@@ -1399,6 +1399,18 @@ - (GMGridViewCell *)dequeueReusableCell
1399 1399 return cell;
1400 1400 }
1401 1401
  1402 +- (GMGridViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier
  1403 +{
  1404 + for (GMGridViewCell *reusableCell in [_reusableCells allObjects]) {
  1405 + if ([reusableCell.reuseIdentifier isEqualToString:identifier]) {
  1406 + [_reusableCells removeObject:reusableCell];
  1407 + return reusableCell;
  1408 + }
  1409 + }
  1410 +
  1411 + return nil;
  1412 +}
  1413 +
1402 1414 //////////////////////////////////////////////////////////////
1403 1415 #pragma mark public methods
1404 1416 //////////////////////////////////////////////////////////////
1  GMGridView/GMGridViewCell.h
@@ -34,6 +34,7 @@
34 34 @property (nonatomic, strong) UIView *contentView; // The contentView - default is nil
35 35 @property (nonatomic, strong) UIImage *deleteButtonIcon; // Delete button image
36 36 @property (nonatomic) CGPoint deleteButtonOffset; // Delete button offset relative to the origin
  37 +@property (nonatomic, strong) NSString* reuseIdentifier;
37 38
38 39 /// Override to release custom data before cell is reused.
39 40 - (void)prepareForReuse;

0 comments on commit a27c51c

Please sign in to comment.
Something went wrong with that request. Please try again.