Is it able to acces selected row position in a sectioned table view within a prepareForSegue
method?
This is my code for Segue:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"CurrentEvent"]) {
Tab1_DetailTableViewController *vc = [segue destinationViewController];
// get the selected index
NSInteger selectedIndex = [[self.tableView indexPathForSelectedRow] row];
}
}
I looked up several methods to acces the position directly, but i didn't find one. I think I have overseen something. Does anybody know a way?
To get the selected indexpath:
NSIndexPath *selectedRowIndexPath = [self.tableview indexPathForSelectedRow];
To get the selected row
NSUInteger selectedRow = selectedIndexPath.row;
To get the selected section
NSUInteger selectedSection = selectedIndexPath.section;
To get the selected cell:
UITableViewCell *selectedCell = [self.tableview cellForRowAtIndexPath:selectedRowIndexPath];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With