0

I am using SWTableViewCell to override Standard TableViewCell to show its swipeable Left & Right Utility Buttons, I am able to access storyboard segue or I am able to segue to detailViewController.

However I've issue with utility buttons setTag Property

How can I access UitlityButtons row's IndexPath whereas I've already tried following.

NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; 
NSLog(@"selected favourite button tag %ld",(long)indexPath);

In simulator it gives me same result each time for each of the row.

selected favourite button tag 0

Any solution to get button's "setTag" property to access index path of the row for those utility buttons in SWTableViewCell when pressed just like in normal tableview

or

How to access setTag Property of Utility buttons to access indexPath of the row containing that specific button when pressed.

Hina Khan
  • 43
  • 8

1 Answers1

1

You must make use of SWTableViewCellDelegate. While returning the cell in the cellForRow method of UITableViewDataSource set the delegate of the cell to be your view controller (cell.delegate = self) and implement the SWTableViewCellDelegate protocol.

SWTableViewCellDelegate:

- (void)swipeableTableViewCell:(SWTableViewCell *)cell didTriggerLeftUtilityButtonWithIndex:(NSInteger)index;
- (void)swipeableTableViewCell:(SWTableViewCell *)cell didTriggerRightUtilityButtonWithIndex:(NSInteger)index;

In either of these two delegate methods you may access the indexPath of the cell whose utitlity button is pressed ike so:

NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
NSLog(@"Index path: %@", indexPath);

Here you have the indexPath.

Adeel Miraj
  • 2,472
  • 3
  • 22
  • 32