2013-07-12 31 views
0

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

这里的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; 
} 

回答

2

代码有当计算可见单元格的数量上GMGridView的错误。

loadRequiredItems有代码

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

这两条线必须更改的范围内,因此将返回是你的项目数的倍数的最小数目。

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

+0

谢谢,解决了它:) –