trying to figure out how to set the selected image for for a tableViewCell
.
The old way of writing this was cell.selectedImage
but that has bee
According to the Deprecated UITableViewCell Methods doc, you should use the imageView's highlightedImage property as a replacement for selectedImage. For example:
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
cell.imageView.image = [UIImage imageNamed:@"deselected_image.png"];
cell.imageView.highlightedImage = [UIImage imageNamed:@"selected_image.png"];
That didn't worked because you might set the normal state image like this
cell.imageView.image = ///
Try it - It worked for me perfectly!!
UIImageView *selBGView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"urimage_selected.png"]];
cell.selectedBackgroundView = selBGView;
[selBGView release];
UIImageView *BGView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"urimage.png"]];
cell.backgroundView = BGView;
[BGView release];
Try this ...
UIImage *bgImage = [UIImage imageNamed:@"icon_call.png"];
UIImageView *bgImageView = [[UIImageView alloc] initWithImage:bgImage];
[bgImageView setFrame:CGRectMake(280, 2, 30, 38)];
//Finally give this imageView to the cell
[cell.contentView addSubview:bgImageView];
Hope it will solve your problem !
Use this one!:
selectionBackground = [UIImage imageNamed:@"background.png"];
cell.selectedBackgroundView =[[UIImageView alloc] init];
((UIImageView *)cell.selectedBackgroundView).image = selectionBackground;
You can set selected backgroundView like below....
UIImageView *selBGView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"urimage.png"]];
cell.selectedBackgroundView = selBGView;