Answer the question
In order to leave comments, you need to log in
How to get the index of the pressed accessory button?
The problem is that the method in which you can get the index of the pressed accessory button
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath{}
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {}
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:@"details" sender:indexPath];
}
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"workout"]) {
UITableViewCell *cell = (UITableViewCell*)sender;
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
WorkoutTVC *wvc = (WorkoutTVC *) segue.destinationViewController;
wvc.workoutName = [self.listOfWorkoutNames objectAtIndex:indexPath.row];
}
else if ([segue.identifier isEqualToString:@"details"]) {
NSIndexPath *indexPath = [sender isKindOfClass:[NSIndexPath class]] ? (NSIndexPath*)sender : [self.tableView indexPathForSelectedRow];
WorkoutDetailsVC *wdvc = (WorkoutDetailsVC *) segue.destinationViewController;
wdvc.workoutName = [self.listOfWorkoutNames objectAtIndex:indexPath.row];
}
}
Answer the question
In order to leave comments, you need to log in
I don't quite understand what you are doing. Ideally, attach an example project with a demonstration of the problem to the question.
But the following should help you - in the method
"Save" indexPath and manually call
*This is only if the UITableView delegate is a UIViewController, and you probably have it)
And of course, you need to remove the previous performSegue, explicit , or the one that you clung to InterfaceBuilder'e
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question