2011-03-16 68 views
2

我正在为我的项目使用AQGridView。我面临的问题是我无法启用GridView的编辑模式。我想要的是,无论何时点击编辑按钮,删除图标应显示在每个单元格上,单击再次编辑按钮将使编辑模式禁用。如何启用AQGridView编辑模式?

这里是我的代码不除第一个函数工作:

- (void) handleEditModeChange:(NSNotification *) note 
{ 
    if(self.gridView.isEditing) 
    { 
     [self.gridView setEditing:NO animated:YES]; 
       NSLog(@"gridView edit mode"); 
    } 
    else 
    { 

     [self.gridView setEditing:YES animated:YES]; 
     NSLog(@"gridView NOT edit mode"); 
    } 

} 


- (UITableViewCellEditingStyle)gridView:(AQGridView *) aGridView editingStyleForRowAtIndex:(NSUInteger) index { 
    NSLog(@"editing style"); 

    // Detemine if it's in editing mode 
    if(self.gridView.isEditing) { 
     return UITableViewCellEditingStyleDelete; 
    } 
    return UITableViewCellEditingStyleNone; 
} 


- (void) gridView:(AQGridView *) aGridView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 
    forRowAtIndex:(NSUInteger) index { 

    NSLog(@"editing"); 
} 

- (BOOL)gridView:(AQGridView *) aGridView canEditRowAtIndex:(NSUInteger) index { 
    NSLog(@"canEditRowAtIndex"); 
    return YES; 
} 

这些代码是在与AQGridViewDelegate,AQGridViewDataSource已经comforms视图控制器。

上面的第一个函数可以正常工作,但第二个函数不会因为某种原因而被调用。

下面的数据源函数可以正常工作。

- (AQGridViewCell *) gridView: (AQGridView *) aGridView cellForItemAtIndex: (NSUInteger) index; 

我是这个新手初学者。有人可以告诉我,如果这是可能的,或者如果我做错了什么?

任何建议,我明白了。

回答

5

AQGridView似乎没有实现编辑功能。如果你想处理熟悉的表格编辑按钮中的单元格删除,那么你必须自己做。在每个相册单元上放置一个隐藏的删除按钮,当你点击一个自定义的“编辑”按钮时,就可以看到它。点击删除:

[gridArray removeObjectAtIndex:[albumCell displayIndex]]; 
NSIndexSet* set = [NSIndexSet indexSetWithIndex:[albumCell displayIndex]]; 
[gridView beginUpdates];  
[gridView deleteItemsAtIndices:set withAnimation:AQGridViewItemAnimationFade]; 
[gridView endUpdates];