开发者

How to unselect a UITableViewCell when UITableView has scrolled?

How can I unselect a UITableViewCell when UITab开发者_C百科leView has scrolled?


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?


You could use the following line in cellForRowAtIndexPath to unselect row after table view will be scrolled:

[_tableView selectRowAtIndexPath:0 animated:NO scrollPosition: UITableViewScrollPositionNone];

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜