2012-04-28 49 views
3

當我點擊它選擇一個小區,但是它停留在觸摸了藍色。我希望藍色突出顯示可以保持聯繫(但重要的是首先突出顯示)。表視圖細胞不觸摸失去亮點了

這最後的答案in this post提到一些關於willSelectRowAtIndexPath:,但我無法弄清楚如何使用做我想做的。另外,我確實需要didSelectRowAtIndexPath:仍然被稱爲,我只是希望細胞不會觸摸到。

回答

5

使用以下在適當情況下:

[tableView deselectRowAtIndexPath:indexPath animated:YES]; 

例如在didSelectRowAtIndexPath

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
     [tableView deselectRowAtIndexPath:indexPath animated:YES]; 
} 

這將取消選定指定索引路徑的行。

您還可能有意clearsSelectionOnViewWillAppear財產UITableViewController。如果此屬性設置爲yes,則控制器在出現表格時清除選擇。默認情況下,它設置爲YES。

Reference