我已经把图像放入我的tableview单元格中,图像位于某个URL .. 我的问题是当我的tableView已经显示数据时, 然后滚动该表查看&下来,它会需要一段时间或延迟才会对滚动作出反应。图像在TableView单元格导致延迟滚动
我发现问题出在位于URL中的图像,我还需要显示每个图像tableview单元格。 任何想法如何解决它?还是要进行优化?
这里是我的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
// Set up the cell
NSUInteger row = [indexPath row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
NSArray *arrLocal = [m_list objectAtIndex:row];
if ([arrLocal count] > 0) {
cell.textLabel.text = [arrLocal objectAtIndex:2];
cell.textLabel.font = [UIFont boldSystemFontOfSize:14];
cell.detailTextLabel.text = [arrLocal objectAtIndex:3];
cell.detailTextLabel.font = [UIFont systemFontOfSize:12];
//sample url of the image: http://www.mysite.com/images/DealExtreme/2657_1_small.jpg
NSString *strTemp = [[NSString alloc] initWithString:@"http://www.mysite.com/"];
NSString *urlString = [strTemp stringByAppendingString: [arrLocal objectAtIndex:1]];
NSURL *url = [NSURL URLWithString:urlString];
UIImage *image = [UIImage imageWithData: [NSData dataWithContentsOfURL:url]];
cell.imageView.image = image;
[strTemp release];
}
return cell;
}
是的,这是...谢谢 – 2010-09-10 16:39:06