2012-03-16 35 views
0

調用cellForItemAtIndex方法在我的iPad應用程序,我使用AQGridViewAQGridView:無法手動

它有很多卡。

按鈕單擊我正在更改圖像數組(意味着替換圖像)。

- 用我在下面寫的方法加載圖像的代碼。

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

******現在方法被調用兩次occassions。**

1.第一時間時它顯示細胞。(清分)。

** 2.當您滾動AQGridView。******

下面是該方法的堆棧.. enter image description here

現在,當我手動調用

LayoutSubviews 

OR 

[self.gridView reloadData]; 

由於AQGridView的這些方法有些參數不同。

它根本不工作。平均無法調用該方法。

所以,我打電話給你的方法,你有任何其他的解決方案。

for(int i=0;i<[toShowArray count];i++) 
    { 
    [self.gridView.dataSource gridView:self.gridView cellForItemAtIndex:i]; 
    } 

回答

2

[self.gridView reloadData];最終應該調用cellForItemAtIndex只要你迷上了這樣的數據源:

self.gridView.dataSource = self; 

但既然你問其他的解決方案,這應該調用cellForItemAtIndex的每個元素,太:

int dataElemCount = [toShowArray count]; 
NSIndexSet* indices = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, dataElemCount)]; 
[self.gridView beginUpdates]; 
[self.gridView reloadItemsAtIndices:indices withAnimation:AQGridViewItemAnimationFade]; 
[self.gridView endUpdates]; 

請注意,reloadItemsAtIndices只適用於beginUpdatesendUpdates。您也可以將動畫更改爲您喜歡的任何其他AQGridViewItemAnimation

+0

非常感謝您的回覆。 – 2012-07-18 10:45:14

+0

我需要檢查。 – 2012-07-18 10:45:23

+0

如果確實對您有幫助,您可能需要將此答案標記爲已接受;) – christoph 2012-08-10 11:07:31