Mo Asif
Mo Asif

Reputation: 25

Selecting row while scrolling

I have a program that selects rows at different times which works perfectly fine. But when i try to scroll down and try to select another row "out of view" while a row has already been selected by my program some where, it doesn't allow me to select that row which i clicked on. It only works if the my selected row is in the current displayed cells or display view. I have enabled multiple selection but still doesn't work.

-I've also find out that didSelectRowAtIndex isn't get called when selecting row outside the view where the program has already selected a row

Upvotes: 0

Views: 402

Answers (1)

Mo Asif
Mo Asif

Reputation: 25

I have found a solution. didSelectRowAtIndex didn't get called because my scroll position of tableView was set to UITableViewScrollPositionTop and this wasn't allowing me to select another row outside the view. All i did was to change it to UITableViewScrollPositionNone And adding scrollToRowAtIndexPathwith scrolling position to none will allow minimum scroll with selected row visible at bottom.

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:*rows inSection:0]; // set to whatever you want to be selected first
[tableview selectRowAtIndexPath:indexPath animated:NO  scrollPosition:UITableViewScrollPositionNone];
[tableview scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionNone animated:NO];
}

Upvotes: 1

Related Questions