我正在列表视图中从 Web 服务获取图像,但我想在网格视图中显示它们。当我在列表视图中显示图像时,在网格视图中我该怎么做?请帮助。这是我的代码的外观:-
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *CELLIDENTIFIER=@"CELL";
UITableViewCell *cell=nil;
if (cell==nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CELLIDENTIFIER] autorelease];
CGRect imageFrame = CGRectMake(2, 8, 80, 60);
NSURL *url = [NSURL URLWithString:[arrayListG objectAtIndex: [indexPath row]]];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[[UIImage alloc] initWithData:data] autorelease];
UIImageView *customImage = [[[UIImageView alloc] initWithFrame:imageFrame] autorelease];
customImage.image=img;
[cell.contentView addSubview:customImage];
}
return cell;
}