- (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通知觀察者;調用此方法不會產生任何滾動到取消行。