在我的UITableView中,我需要获取用户的事件,所以当单元格被选中(选中)时,我把btn_checked.png
当它未选中时,我把btn_unchecked.png
。当它被选中时更改单元格的图像
我猜,我尝试做应该在didSelectRowAtIndexPath
方法,所以这是我的代码:
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSArray *listData =[self->tableContents objectForKey:
[self->sortedKeys objectAtIndex:[indexPath section]]];
UITableViewCell* theCell = [tableView cellForRowAtIndexPath:indexPath];
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"btn_unchecked.png"]];
theCell.accessoryView = imageView;
}
我的代码段不能正常工作,所以btw_unchecked.png
没有放置于行被检查,而且,我需要获得选中/取消选中的事件以将正确的图像放到正确的事件中。 Thanx提前。