原来如此简单,哪 怕是读取的是网络中的图片也是这样的:
static NSString *CellIdentifier = @"Cell";
CHCustomDetailCell *cell = (CHCustomDetailCell *)[tableViewDemo dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = (CHCustomDetailCell *)[[[CHCustomDetailCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.cusDetailLabel.text = @"荷叶烧肉@烤肉季 限时半价";
cell.cusDetailImagView.image = nil;
GCCDetailObject *object = [[GCCategoryDetailMgr ShareInstanceSearchMgr].cdArray objectAtIndex:indexPath.row];
NSURL *url = [NSURL URLWithString:object.cImage];
if (cell.cusDetailImagView.image == nil) {
cell.cusDetailImagView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]];; //这个即是读取的网络图片,本地图片就更不用说了
}
CGFloat hei = cell.cusDetailImagView.image.size.height;
CGFloat wid = cell.cusDetailImagView.image.size.width;
CGFloat zhenshi = (320 * hei / wid);
cell.cusDetailImagView.frame = CGRectMake(0, 0, 320, zhenshi);
cell.cusDetailLabel.frame = CGRectMake(0, zhenshi - 60, 320, 60);
[cell setFrame:CGRectMake(0, 0, 320, zhenshi)];
return cell;