2014-09-10 57 views
2

當向左滑動刪除(在我的情況下爲void)一行時,黑色表格視圖出現白色時出現問題。在編輯模式下更改UITableViewCells的背景

我試着從ViewController一直到TableViewCell的內容的每一步,設置顏色的每一個可能的參數。

我設法得到它深灰爲「選擇」與CellForRowAtIndex如下:

UIView *bgColorView = [[UIView alloc] init]; 
    bgColorView.backgroundColor = [UIColor darkGrayColor]; 
    [cell setSelectedBackgroundView:bgColorView]; 

所以我想解決的辦法是類似的東西。

我在iPhone上有一個類似的設置,其中TableView是在一個TableViewController中沒有發生問題。在這種特殊情況下,TableView是在一個常規的ViewController中。

附上截圖。請指教。編輯:請注意,空格不是出現在無效按鈕旁邊的按鈕。它是根據您拖動單元格的距離改變大小的空白空間。如果釋放細胞,白色空間會完全消失,但反彈會顯示白色空間。

刷卡左(在運動):

enter image description here

刷卡左(釋放):

enter image description here

Unswiped:

enter image description here

+0

您可以提供一個完整的單元格屏幕快照,並且不顯示刪除選項。同時也發佈你的代碼,以便查找問題。 – nikhil84 2014-09-10 11:27:06

+0

你想要什麼代碼部分?除了CanEditRowForIndex允許使用CanEditRowForIndex之外,實際刷卡中沒有涉及代碼,它只是爲我的表返回true。未添加另一個屏幕截圖。 – nickdnk 2014-09-10 11:51:37

回答

2

哇 - 原來我只需要實現以下方法:

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { 

    cell.backgroundColor = [UIColor blackColor]; 

} 

諷刺的是我搜索高和低的解決方案,才發現的15分鐘我問後。幾個星期以來一直困擾着我。

啊,好吧,也許有人在這個問題上絆倒了。