2013-07-12 60 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

謝謝,解決了它:) –