我有一些代码可以改变在分组表格视图中完美工作的单元的背景图像。但是,并不是一张普通的表格。有谁知道为什么这些行为有所不同?我想要做的就是给表格单元格添加一个背景图像(普通)iPhone:普通表问题。没有出现单元背景图像
这对分组表格视图完美。我是否需要自定义单元格才能使用普通视图?
感谢西蒙
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
UniversalAppAppDelegate *appDelegate = (UniversalAppAppDelegate *)[[UIApplication sharedApplication] delegate];
NSArray *rowData;
// Check see if section Data is populated
if (self.sectionData == nil) {
rowData = [(NSDictionary *)[tableData objectAtIndex:indexPath.section] objectForKey:@"SectionItems"];
} else {
rowData = [(NSDictionary *)[sectionData objectAtIndex:indexPath.section] objectForKey:@"SectionItems"]; //[self.sectionData objectAtIndex:indexPath.section];
}
NSDictionary *cellDetails = [rowData objectAtIndex:indexPath.row];
// Clear any previous imageview
UIView *view = [cell.backgroundView viewWithTag:99];
if (view != nil)
[view removeFromSuperview];
// Add a new imageview
NSString *filename = [cellDetails objectForKey:@"TableItemFullImage"];
if (filename.length > 0) {
UIImageView *cellImageView = [[UIImageView alloc] initWithImage:[appDelegate imageForImageID:[cellDetails objectForKey:@"TableItemFullImage"] imageExtension:[cellDetails objectForKey:@"TableItemFullImageType"]]];
cellImageView.tag = 99;
CGRect newFrame = cell.backgroundView.bounds;
cellImageView.frame = newFrame;
[cell.backgroundView addSubview:cellImageView];
[cellImageView release];
}
}
这么简单,完全工作 – Burf2000 2010-09-23 13:32:48