I want to have selected index for UITableView
. I have written following code:
NSIndexPath *index = [NSIndexPath indexPathForRow:1 inSection:0]; [tableView scrollToRowAtIndexPath:index atScrollPosition:UITableViewScrollPositionTop animated:YES];
This always work for 1st item. I want to have selected index in indexPathForRow.
Please help. Thanks.
NSIndexPath *selectedIndexPath = [tableView indexPathForSelectedRow];
Get current selected row. May be helpful if you have only one section.
- (NSUInteger)currentSellectedRowIndex { NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow]; if (selectedIndexPath) { return selectedIndexPath.row; } else { return NSNotFound; } }
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