Skip to content

Commit

Permalink
Added the support to identify a cell and reuse it with a specific ide…
Browse files Browse the repository at this point in the history
…ntifier.
  • Loading branch information
jcouture committed Jan 27, 2012
1 parent 631774c commit a27c51c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions GMGridView/GMGridView.h
Expand Up @@ -91,6 +91,7 @@ typedef enum

// Reusable cells
- (GMGridViewCell *)dequeueReusableCell; // Should be called in GMGridView:cellForItemAtIndex: to reuse a cell
- (GMGridViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier;

// Cells
- (GMGridViewCell *)cellForItemAtIndex:(NSInteger)position; // Might return nil if cell not loaded for the specific index
Expand Down
12 changes: 12 additions & 0 deletions GMGridView/GMGridView.m
Expand Up @@ -1399,6 +1399,18 @@ - (GMGridViewCell *)dequeueReusableCell
return cell;
}

- (GMGridViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier
{
for (GMGridViewCell *reusableCell in [_reusableCells allObjects]) {
if ([reusableCell.reuseIdentifier isEqualToString:identifier]) {
[_reusableCells removeObject:reusableCell];
return reusableCell;
}
}

return nil;
}

//////////////////////////////////////////////////////////////
#pragma mark public methods
//////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions GMGridView/GMGridViewCell.h
Expand Up @@ -34,6 +34,7 @@
@property (nonatomic, strong) UIView *contentView; // The contentView - default is nil
@property (nonatomic, strong) UIImage *deleteButtonIcon; // Delete button image
@property (nonatomic) CGPoint deleteButtonOffset; // Delete button offset relative to the origin
@property (nonatomic, strong) NSString* reuseIdentifier;

/// Override to release custom data before cell is reused.
- (void)prepareForReuse;
Expand Down

0 comments on commit a27c51c

Please sign in to comment.