I created a TableView with a custom UITableViewCell. The button is associated with each row of the table. Now I want to know the line number by pressing a button, so that I know which line button is pressed. I tried several things found on the stack, but nothing works.
I tried this code -:
-(void)button1Tapped:(id)sender { UIButton *senderButton = (UIButton *)sender; UITableViewCell *buttonCell = (UITableViewCell *)[senderButton superview]; UITableView* table = (UITableView *)[buttonCell superview]; NSIndexPath* pathOfTheCell = [table indexPathForCell:buttonCell]; NSInteger rowOfTheCell = [pathOfTheCell row]; NSLog(@"rowofthecell %d", rowOfTheCell); }
But this also does not work.
Thanks for helping me.
source share