5

I have created a method - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath { for UITableViewCellAccessoryDetailDisclosureButton.

Now I want to use UITableViewCellAccessoryDisclosureIndicator in place of UITableViewCellAccessoryDetailDisclosureButton.

Is there any difference between UITableViewCellAccessoryDetailDisclosureButton and UITableViewCellAccessoryDetailDisclosureButton?

Rob
  • 25,984
  • 32
  • 109
  • 155
Varsha
  • 560
  • 5
  • 18

3 Answers3

6

Apple HIG suggests that you use UITableViewCellAccessoryDisclosureIndicator to navigate through hierarchical data, and UITableViewCellAccessoryDetailDisclosureButton to perform some action, possible bringing up an edit view, that may change the data. However, most programmers seem to ignore this.

You can implement the delegate method tableView:didSelectRowAtIndexPath: like this:

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
    [self tableView:tableView didSelectRowAtIndexPath:indexPath];
}

Or vice versa.

Paul Lynch
  • 19,769
  • 4
  • 37
  • 41
2

There is difference. UITableViewCellAccessoryDetailDisclosureButton is actually a button but UITableViewCellAccessoryDisclosureIndicator is not.

You can use UITableViewCellAccessoryDisclosureIndicator instead of UITableViewCellAccessoryDetailDisclosureButton but you can not get the tableView:accessoryButtonTappedForRowWithIndexPath: method called when you tap on the UITableViewCellAccessoryDisclosureIndicator as it is not a button.

EmptyStack
  • 51,274
  • 23
  • 147
  • 178
  • how can i call tableView:accessoryButtonTappedForRowWithIndexPath: method by using UITableViewCellAccessoryDisclosureIndicator ???...or how can i use custom button on UITableViewCellAccessoryDetailDisclosureButton so that it can perform action by tapping on it..?? – Varsha Oct 11 '11 at 06:16
  • Create a button with target/action and assign it as accessory view. Omit the tableView:accessoryButtonTappedForRowWithIndexPath: method. – EmptyStack Oct 11 '11 at 06:20
  • can you please explain it??,...how can i add button on UITableViewCellAccessoryDetailDisclosureButton ???.. – Varsha Oct 11 '11 at 06:22
  • And [this link](http://stackoverflow.com/questions/851498/how-to-add-a-button-without-using-custom-cell-on-a-uitableview) – EmptyStack Oct 11 '11 at 06:51
0

Yes, they're different.

Use UITableViewCellAccessoryDetailDisclosureButton when the user tapping the blue button performs a different action than tapping the rest of the row, even if the rest of the row does nothing.

Use UITableViewCellAccessoryDisclosureIndicator when the entire row is tappable and produces the same action.

If your behaviour is something else, use some other mechanism.

Steven Fisher
  • 44,462
  • 20
  • 138
  • 192