Hi there
I have a some code that changes the background image of a cell which works perfectly in a grouped table view. However, does not in a plain table. Does anyone know why these behave differently? All I want to do is add a background image to a table cell (plain)
This works perfectly on a grouped table view. Do I need a custom cell for it to work with a plain view?
Thanks Simon
-(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];
}
}