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

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容