简体   繁体   中英

How to get the swiped cell index path in didTriggerRightUtilityButtonWithIndex delegate?

I have done UITableView cell swipe according to this tutorial

http://www.appcoda.com/swipeable-uitableviewcell-tutorial/

Now I want to get the indexpath of that particular cell that swiped inside this delegate

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

How can I get the indexpath of currently swiped Cell.

You can create instance of Your table view by binding outlet from Storyboard to your .h file, like

@interface SwipeTableViewController : UITableViewController <SWTableViewCellDelegate>
    @property (strong, nonatomic) IBOutlet UITableView *yourTableView;

@end

In the same method , you can get NSIndexPath with help of cell instance of method.

- (void)swipeableTableViewCell:(SWTableViewCell *)cell didTriggerLeftUtilityButtonWithIndex:(NSInteger)index {
    NSIndexPath *indexPath = [self.yourTableView indexPathForCell:cell];
    NSLog(@"%i",indexPath.row);
    ....
}

Hope this help you.

Maintain an instance of UITableView *myTableView .

//Get the IndexPath
NSIndexPath *indexPath = [myTableView indexPathForCell:cell];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM