我subclassed UITableViewCell并添加一个按钮。当按钮被触摸时,我该如何回应事件?我还需要知道按下哪个索引路径。自定义UITableViewCell与按钮
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"CustomTableCell";
CustomTableCell *cell = (CustomTableCell *)
[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle]
loadNibNamed:@"CustomTableCell"
owner:nil options:nil];
for (id currentObjects in topLevelObjects){
if ([currentObjects isKindOfClass:[StatusTableCell class]]){
cell = (StatusTableCell *) currentObjects;
break;
}
}
}
cell.customButton.tag = indexPath.row;
return cell;
}
[参考此链接] [1] [1]:http://stackoverflow.com/questions/869421/using-a-custom-image-for-a-uitableviewcells-accessoryview-并有回应 – HelmiB