Reputation: 60879
How can I unselect a UITableViewCell when UITableView has scrolled?
Upvotes: 2
Views: 3156
Reputation: 1
You could use the following line in cellForRowAtIndexPath to unselect row after table view will be scrolled:
[_tableView selectRowAtIndexPath:0 animated:NO scrollPosition: UITableViewScrollPositionNone];
Upvotes: 0
Reputation: 1104
I would imagine you could use the following answer:
Detecting UITableView scrolling
Make sure your .h file looks similar to the following:
@interface ItemSelectController : UITableViewController <UIScrollViewDelegate> {
Then place the following in your .m to detect when scrolling occurs and deselect whatever cell is selected.
-(void) scrollViewDidScroll:(UITableView *)sender {
[sender deselectRowAtIndexPath:[sender indexPathForSelectedRow] animated:YES];
}
The UIScrollViewDelegate in those funny brackets at the end means it implements that protocol. Meaning you have access to functions like scrollViewDidScroll. The top function up there overrides it to do what you want. You wouldn't happen to have multi-select on, would you?
Upvotes: 4