ボタンをクリックしたときに行を選択しないため、機能しません。
2つのボタンを使用して、セグエをボタンから切断し、IBで2つの手動セグエを実行してから、そのようなコードを追加してそれらを処理します。
-(void)button1Pressed:(id)sender {
UITableViewCell *clickedCell = (UITableViewCell *)[[sender superview] superview];
NSIndexPath *clickedButtonIndexPath = [self.homeTableView indexPathForCell:clickedCell];
...
[self performSegueWithIdentifier:@"YourManualSegueIdentifier1" sender:self];
}
2番目のオプションの編集:
MyTableViewCell.h内:
@interface MyTableViewCell : UITableViewCell
...
@property (strong, nonatomic) NSIndexPath *cellIndexPath;
...
@end
MyTableViewCell.m内:
-(void)button1Pressed:(id)sender {
...
NSInteger row = cellIndexPath.row;
...
}
MyTableViewController.m内:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
MyTableViewCell *cell = (MyTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[MyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// remember index here!
[cell setCellIndexPath:indexPath];
....
return cell;
}