2

UIGridViewRepoを使用 して、フィードから画像のグリッド ビューを作成しています。しかし、次のコードを使用すると、同じ画像がすべてのグリッドに表示されます。

-(UIGridViewCell *) gridView:(UIGridView *)grid cellForRowAt:(int)rowIndex AndColumnAt:(int)columnIndex
{
Cell *cell = (Cell *)[grid dequeueReusableCell];

if (cell == nil) {
    cell = [[Cell alloc] init];
}


NSString *imageLink = [item objectForKey:@"link"];

NSURL * imageURL = [NSURL URLWithString:imageLink];
NSData * imageData = [NSData dataWithContentsOfURL:imageURL];
UIImage * image = [UIImage imageWithData:imageData];

cell.thumbnail.image = image;
return cell;
}

配列のすべての画像でグリッドを埋めるにはどうすればよいですか?

前もって感謝します

4

1 に答える 1

1

あなたのgridView's cellForRowAtメソッドでは、same image linkfor allを使用していますUIGridViewCell

Get different link用途にfeed応じてrowIndex and column indexdifferent image

編集:たとえば、4つの画像が連続していると仮定します

 int column = 4;
 int row = totalImage / column;

 for(int i=1; i<=totalImage; i++)
 {
    for(int j=1; j<=row; j++)
    {
       for(int m=1; m<=column; m++)
       {
          // j and m 's image
       }
    }
 }
于 2013-01-10T09:38:41.463 に答える