我有表格视图,我想在选择时将图像添加到单元格,如果选择了新单元格,则将图像更改为选定单元格
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
cell = [self.tableView cellForRowAtIndexPath:indexPath];
cell.imageView.image=[UIImage imageNamed:@"Activity.png"];
}
- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
cell = [self.tableView cellForRowAtIndexPath:indexPath];
cell.imageView.image=[UIImage imageNamed:@"Activity2.png"];
NSUInteger row = indexPath.row;
}
这是我认为我想要的代码
if (indexPath.row==0) {
cell.imageView.image=[UIImage imageNamed:@"Activity2.png"];
NSLog(@"Cell Clicked row 0");
if(indexPath.row==1){
NSLog(@"Cell Clicked row 1 in 0");
cell.imageView.image=[UIImage imageNamed:@"Catalog"];
}
}
if (indexPath.row==1) {
cell.imageView.image=[UIImage imageNamed:@"Catalog2.png"];
NSLog(@"Cell Clicked row 1");
if(indexPath.row==0){
NSLog(@"Cell Clicked row 0 in 1");
cell.imageView.image=[UIImage imageNamed:@"Activity"];
}
}
new code added that how i want images on cell when new cell is selected.