Permalink
Browse files

Adding the ability to disallow the editing/deleting of a cell through

another delegate call.
  • Loading branch information...
1 parent 23c4698 commit cdfb75eb48e8ab9bb4774ecefa79394627319bd7 @Bringo committed Feb 12, 2012
Showing with 15 additions and 2 deletions.
  1. +1 −1 GMGridView/API/GMGridView.h
  2. +14 −1 GMGridView/API/GMGridView.m
@@ -112,7 +112,7 @@ typedef enum
@optional
// Required to enable editing mode
- (void)GMGridView:(GMGridView *)gridView deleteItemAtIndex:(NSInteger)index;
-
+- (BOOL)GMGridView:(GMGridView *)gridView shouldEditItemAtIndex:(NSInteger)index;
@end
@@ -353,9 +353,22 @@ - (void)setEditing:(BOOL)editing
&&![self isInTransformingState]
&& ((self.isEditing && !editing) || (!self.isEditing && editing)))
{
+ NSInteger index = 0;
for (GMGridViewCell *cell in [self itemSubviews])
{
- [cell setEditing:editing];
+ if (editing && [self.dataSource respondsToSelector:@selector(GMGridView:shouldEditItemAtIndex:)])
+ {
+ if ([self.dataSource GMGridView:self shouldEditItemAtIndex:index])
+ {
+ [cell setEditing:editing];
+ }
+ }
+ else
+ {
+ [cell setEditing:editing];
+ }
+
+ index++;
}
_editing = editing;

0 comments on commit cdfb75e

Please sign in to comment.