由于我是 iPad 应用程序开发的新手,请帮助我解决简单的问题。
我想在服务器的 tableview 中显示图像。它显示正确。
但是当我向上滚动表格并再次回到那里时,它将再次从服务器下载图像数据。
请帮我。
编辑:
表视图:cellForRowAtIndexPath:
static NSString *CellIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
[cell setSelectionStyle:UITableViewCellSelectionStyleBlue];
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 1024, 75)];
[imgView setImage:[UIImage imageNamed:@"strip_normal.png"]];
[imgView setHighlightedImage:[UIImage imageNamed:@"strip_hover.png"]];
[cell addSubview:imgView];
[imgView release];
UIImageView *imgView1 = [[UIImageView alloc] initWithFrame:CGRectMake(5, 5, 64, 64)];
imgView1.tag = indexPath.row;
UIImage *img = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.abc.com/abc/%@.png", [[arrMyCourses objectAtIndex:indexPath.row] valueForKey:@"CourseNumber"]]]]];
[imgView1 setImage:img];
[cell addSubview:imgView1];
[imgView1 release];
return cell;
提前致谢。