开发者

How to enable AQGridView edit mode?

I am using AQGridView for my project. The problem I'm facing is that I'm not able to enable my gridView's edit mode. What I want is that whenever the edit button gets clicked, the delete icon should be shown on each cell, click the edit again button will make that edit mode disable.

here are my codes which don't work except the first function:

- (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;
}

These codes are in a view controller which comforms with AQGridViewDelegate, AQGrid开发者_Python百科ViewDataSource already.

The first function above works fine but the second function does not get called for some reason.

The datasource function like the one below works fine.

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

I am new beginner for this. Could some people please tell me if this is possiable or if I am doing something wrong?

Any suggestion I appreciate.


AQGridView does not seem to implement the editing features. If you want to handle deletion of cells in the familiar table editing buttons then you have to do it yourself. Put a hidden delete button on each of the Album Cells and when you click a custom "Edit" button make it visible. On clicking delete:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜