GMGridViewCell没有动摇

时间:2013-07-12 08:54:08

标签: gmgridview gmgridviewcell

我在我的应用程序中使用了GMGridView。当我改变方向时,一切都很好,但是如果我再次更改它并进入编辑模式,除了右下角的可见细胞外,所有细胞都会被震动。 GmGridView作为子视图添加到控制器,它也不占用整个屏幕。我已经尝试销毁它并在发生轮换通知时重新创建它...相同的行为。此外,我已经创建了一个自定义视图,其中包含多个按钮和标签,我将其设置为GMGridViewCell的contentView。

这是cellForItemAtIndex的代码

- (GMGridViewCell *)GMGridView:(GMGridView *)gridView cellForItemAtIndex:(NSInteger)index {
    UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
    GMGridViewCell *cell = [gmGridView dequeueReusableCell];

    if (!cell) {
        CGSize cellSize = [self GMGridView:gmGridView sizeForItemsInInterfaceOrientation:orientation];

        cell = [[GMGridViewCell alloc] initWithFrame:CGRectMake(0, 0, cellSize.width, cellSize.height)];
        cell.deleteButtonIcon = [UIImage imageNamed:@"delete_button"];
        cell.deleteButtonOffset = CGPointMake(0, 0);


    }     

    CustomGridViewCell *gridViewContent = [CustomGridViewCell getNewGridViewCellForOrientation:orientation];
    ContentData *data = [wishlistContentArray objectAtIndex:index];
    [gridViewContent setuprWithContent:data];
    cell.contentView = gridViewContent;

    if (!gridViewContent.delegate)
        gridViewContent.delegate = self;

    return cell;
}

1 个答案:

答案 0 :(得分:2)

GMGridView在计算可见单元格数时存在错误。

loadRequiredItems中有这两行代码

NSRange rangeOfPositions = [self.layoutStrategy rangeOfPositionsInBoundsFromOffset: self.contentOffset];
NSRange loadedPositionsRange = NSMakeRange(self.firstPositionLoaded, self.lastPositionLoaded - self.firstPositionLoaded);

您必须更改范围,以便返回最小数字,该数字是您单元格中项目数的倍数。

例如,如果一行中有2个单元格,那么现在代码将返回{0,5}的范围,但它应该是{0,6}。