Reputation: 1878
How to change cell background image on click on cell in iphone????I have tried following but it is not working....
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0,0,320,50) reuseIdentifier:myid] autorelease];
cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"myImage.png"]];
}
Upvotes: 3
Views: 1244
Reputation: 87
cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mImage.png"]]
Upvotes: 0
Reputation: 2941
You can change the selectionType of UITableView
using
cell.setSelectionStyle = [UITableViewSelectionStyleGray/Blue/None] (only 3 types)
some syntex error in above code try with proper syntex
by default it will be blue...
Upvotes: 0
Reputation: 28720
cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"myImage.png"]];
In the above piece of code you forget to autorelease; also have you set the delegate of the tableview? Set a breakpoint on the tableview:didselectRowAtIndexpath
method to check if it is called or not.
BTW your code seems right.
Upvotes: 2