我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