Designer023
Designer023

Reputation: 2002

cell view disclosure button and relevent method

I have been struggling with a cell disclosue button... First it was saying it is depreciated as I was using:

-(UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath {
 return UITableViewCellAccessoryDetailDisclosureButton;
}

So I commented that out and added the disclosure to the cell in the configureCell using:

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.editingAccessoryType = UITableViewCellAccessoryNone;

However now my disclosure button does nothing. What do I need to add to get the disclosue button to work. All my googling has come up with are other depreciated methods. Any help or pointers would be much appreciated.

Upvotes: 5

Views: 7185

Answers (3)

Ketan P
Ketan P

Reputation: 4379

Delegate Method In Swift 3.0

func tableView(_ tableView: UITableView, accessoryButtonTappedForRowWith indexPath: IndexPath) {

}

But for Use this delegate : you can use either of following two accessory Type :

cell.accessoryType = .detailDisclosureButton
cell.accessoryType = .detailButton

Upvotes: 0

James Huddleston
James Huddleston

Reputation: 8448

If you actually want a detail disclosure button, make sure that you are setting your cell accessory type to UITableViewCellAccessoryDetailDisclosureButton. (Your sample code shows UITableViewCellAccessoryDisclosureIndicator.) You handle detail disclosure button taps in your table view delegate's tableView:accessoryButtonTappedForRowWithIndexPath: method. You handle row selection (no matter what the accessory view is) in your table view delegate's tableView:didSelectRowAtIndexPath: method.

Upvotes: 14

Jorge
Jorge

Reputation: 2066

Use this method in you table view delegate

    - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath

Upvotes: 3

Related Questions