tableView:accessoryButtonTappedForRowWithIndexPath:の行にアクセサリ ビューが設定されている場合、メソッドは呼び出されないとドキュメントに記載されていindexPathます。このメソッドは、プロパティが有効な場合にのみ呼び出され、accessoryViewプロパティをnil使用および設定しaccessoryTypeて組み込みアクセサリ ビューを表示する場合にのみ呼び出されます。
私が理解しているように、accessoryView相互accessoryTypeに排他的です。を使用するaccessoryTypeと、システムは期待どおりに呼び出しtableView:accessoryButtonTappedForRowWithIndexPath:ますが、それ以外の場合は自分で処理する必要があります。
Apple がこれを行う方法Accessoryは、SDK のサンプル プロジェクトに示されています。cellForRowAtIndexPathdataSource デリゲートのメソッドで、ターゲット/アクションをカスタム アクセサリ ボタンに設定します。indexPathをアクションに渡すことができないため、補助メソッドを呼び出して対応するものを取得しindexPath、結果をデリゲート メソッドに渡します。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
...
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
...
// set the button's target to this table view controller so we can interpret touch events and map that to a NSIndexSet
[button addTarget:self action:@selector(checkButtonTapped:event:) forControlEvents:UIControlEventTouchUpInside];
...
cell.accessoryView = button;
return cell;
}
- (void)checkButtonTapped:(id)sender event:(id)event{
NSSet *touches = [event allTouches];
UITouch *touch = [touches anyObject];
CGPoint currentTouchPosition = [touch locationInView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint: currentTouchPosition];
if (indexPath != nil){
[self tableView: self.tableView accessoryButtonTappedForRowWithIndexPath: indexPath];
}
}
何らかの理由で、あなたの設定はaccessoryViewのケースに当てはまるようです。accessoryTypeInterface Builder を使用する代わりに with コードを設定しようとしましたか?