Вот мой пример полного решения вашего запроса:
В моем подклассе UITableViewCell (я называю это RNWNewItemCell):
-(void)configureCell...
{
// create the button
self.btnSeekDuplicate = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 22, 22)];
// just make it yellow until we get our real image..
self.btnSeekDuplicate.backgroundColor = [UIColor yellowColor];
// add the handler for the button press
[self.btnSeekDuplicate addTarget:self
action:@selector(seekDuplicateButtonWasPressed)
forControlEvents:UIControlEventTouchUpInside];
// make it visible in the table cell...
[self setAccessoryView:self.btnSeekDuplicate];
}
- (void)seekDuplicateButtonWasPressed
{
do something...
}
В моем коде таблицы, который использует ячейку...
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
...
RNWNewItemCell *aNewItemCell = [tableView dequeueReusableCellWithIdentifier:cellIdentifierForNewItemCell forIndexPath:indexPath];
[aNewItemCell configureCell...]
...
}
Обратите внимание, что accessoryButtonTappedForRowWithIndexPath НЕ вызывается при установке accessoryView ячейки таблицы.Возможно, потому что они предполагают, что вы используете представление, которое реагирует на события.