图像似乎覆盖了单元格中的文本,我不确定为什么会这样,但我希望文本覆盖图像。任何帮助是极大的赞赏。
这就是我的代码的样子。
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
CGRect imageFrame = CGRectMake(0, 0, 120, 90);
self.customImage = [[UIImageView alloc] initWithFrame:imageFrame];
[cell.contentView addSubview:self.customImage];
[self.customImage release];
CGRect contentFrame = CGRectMake(100, 2, 198, 30);
UILabel *title = [[UILabel alloc] initWithFrame:contentFrame];
title.tag = 0011;
title.numberOfLines = 2;
title.font = [UIFont boldSystemFontOfSize:12];
[cell.contentView addSubview:title];
[title release];
}
UILabel *title = (UILabel *)[cell.contentView viewWithTag:0011];
title.text = [currentFeed title];
NSString *directoryPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSURL *imgURL = [currentFeed thumbnailURL];
NSArray *parts = [[NSString stringWithFormat:@"%@", imgURL] componentsSeparatedByString:@"/"];
NSString *imageName = [parts objectAtIndex:[parts count]-2];
NSString *filePath = [directoryPath stringByAppendingPathComponent:imageName];
UIImage *myview = [UIImage imageWithContentsOfFile:filePath];
if(myview){
cell.imageView.image = myview;
}else{
NSData* imageDataTemp = [[NSData alloc] initWithContentsOfURL:[currentFeed thumbnailURL]];
if(imageDataTemp){
cell.imageView.image = [UIImage imageWithData:imageDataTemp];
}else{
cell.imageView.image = [UIImage imageNamed:@"youtubeLogo.png"];
}
}
return cell;
}