I have a UITableView
using prototype cell.
The cells have a UIButton
that show a UIViewController
(Modal) using Segue
First make a global int variable selecteIndex
;
In your cell, give your button tag similar to cell's indexPath.row
value
E.g. btn.tag = indexPath.row;
The assing & call action on click of that button
[btn addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
-(void)buttonClicked:(id)sender
{
UIButton *btn = (UIButton*)sender;
selectedIndex = btn.tag;
[self performSegueWithIdentifier:@"segueName" sender:self];
}
Then at end of your view write this function
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"segueName"]) {
viewController *dvc = (viewController *)[segue destinationViewController];
[dvc setSelected:selectedIndex];
};
}