回答
你必須設置的風格cellForRowAtIndexPath
或改變細胞中willSelectRowAtIndexPath
和變回它變成不被選中。 例如
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// ...
cell.selectionStyle = UITableViewCellSelectionStyleBlue; // or an other style
// ...
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// ...
[tableView deselectRowAtIndexPath:indexPath animated:NO];
// ...
}
簡單:
在該方法中:didSelectRowAtIndexPath
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
UIActionSheet *photoPicker ;
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
不是那麼簡單:(請檢查其他評論請 – alex440
這應該工作。我也檢查了IOS7以及檢查你的代碼完整的UItableView代表。 –
放入的UITableView代表以下。
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
[cell setSelected:NO animated:YES];
}
這不起作用 - 它刪除了細胞曾經被選中的指示 - 我想顯示細胞被選中,但第二個用戶將他的手指從細胞中取出,我想取消它 – alex440
您是否考慮處理觸摸事件?
例如:添加一個UITapGestureRecognizer,使用-(CGPoint)locationInView:(UIView *)view
方法檢測正在觸摸哪個單元格。在觸摸開始時將單元格標記爲選中狀態,並在觸摸結束時將其標記爲取消選中狀態。
你把委託給UITableView了嗎?
self.tableView.delegate = self;
這就是爲什麼您遇到此
這不起作用 - 細胞不顯示選擇
在tableView:didSelectRowAtIndexPath:
是 的指示,設置所選屬性使用方法setSelected:animated:
將該單元格設置爲NO
。
E.g.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell * cell = [tableView cellForRowAtIndexPath:indexPath];
[cell setSelected:NO animated:YES];
}
注:
設置細胞的選定的屬性= NO和動畫= YES用上述方法將導致隔膜消失。我發現繞過這個的唯一方法是設置動畫=否,但是,如果我找到另一種方式,我會更新我的答案。
- 1. 如何選擇的CollectionView單細胞和取消選擇所有其它細胞
- 2. UISplitViewController和細胞取消選擇
- 3. 的TableView細胞視頻自動播放
- 4. 中的tableview細胞
- 5. 編程取消選擇和編輯的JTable細胞
- 6. 的iOS的TableView細胞
- 7. 細胞的tableview不滾動順利
- 8. 的tableView細胞 - 從其他的tableView
- 9. 的TableView顯示細胞uncorrectly
- 10. 的TableView細胞代表(Qt.BackgroundRole)
- 11. 單一的tableview細胞
- 12. 定製的tableview細胞
- 13. 可擴展的tableview細胞
- 14. RTL定製的tableview細胞
- 15. 無法選擇或取消DataGridViewCheckBoxColumn細胞編程
- 16. 取消選擇在C#互操作當前編輯細胞
- 17. 細胞得到未選擇不取消命令
- 18. UICollectionView啓用取消選擇細胞,而allowsMultipleSelection禁用
- 19. UIcollection查看多個選擇取消細胞
- 20. UITableView:重置細胞選擇
- 21. 細胞採集它選擇
- 22. JRadionButton自動取消選擇
- 23. 我有自定義的tableview細胞和我在的tableview
- 24. 使細胞出現和消失在TableView中
- 25. 延長細胞高度與labet文本的tableview細胞IOS
- 26. 選擇一個細胞錯誤地標記等幾個細胞作爲「選擇」
- 27. 重複使用多個自定義的tableview細胞
- 28. Excel中:自動化細胞
- 29. IOS的UITableView細胞選擇的背景
- 30. 的UITableView細胞不能選擇
保持選中狀態意味着您的單元格保持藍色狀態? –