2011-03-16 63 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]; 
相關問題