取消tableViewCell 的选中状态

- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath {

//其他代码

[tableView deselectRowAtIndexPath:indexPath animated:YES];// 取消选中

//其他代码

}

- (void)deselectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated

方法的官方文档描述:Deselects a given row identified by index path, with an option to animate the deselection.

Calling this method does not cause the delegate to receive a tableView:willDeselectRowAtIndexPath: or tableView:didDeselectRowAtIndexPath: message, nor does it send UITableViewSelectionDidChangeNotification notifications to observers.

Calling this method does not cause any scrolling to the deselected row.

中文的意思就是:根据 indexPath 以动画的形式取消选中。调用此方法不会造成委托接受tableView:willDeselectRowAtIndexPath和tableView:didDeselectRowAtIndexPath:消息;不给UITableViewSelectionDidChangeNotification通知观察者;调用此方法不会产生任何滚动到取消行。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容