2013-02-24 78 views
0

我的應用程序中有一個UITableView出現問題。我將它設置爲每隔一個表格,仍然有一個單元格總是具有白色背景,而不是[UIColor clearColor]。 我這是怎麼實現的tableView:cellForRowAtIndexPath:UITableView中的奇怪行爲 - 一個單元格顯示不同

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *cellIdent = @"NewSessionCell"; 

    UITableViewCell *cell = [self.tableSubjects dequeueReusableCellWithIdentifier:cellIdent]; 

    if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdent]; 
    } 

    [cell setAutoresizesSubviews:NO]; 
    [cell setBackgroundColor:[UIColor clearColor]]; 

    // set text color and font 
    [cell.textLabel setTextColor:[UIColor whiteColor]]; 
    [cell.textLabel setFont:[UIFont systemFontOfSize:18.0]]; 

    // set clear background for selected cell 
    UIView *backView = [[UIView alloc] initWithFrame:CGRectZero]; 
    backView.backgroundColor = [UIColor clearColor]; 
    [cell setSelectedBackgroundView:backView]; 

    // set highlight text color to dark gray 
    float colValue = 0.2; 
    [cell.textLabel setHighlightedTextColor:[UIColor colorWithRed:colValue green:colValue blue:colValue alpha:1]]; 

    // set title 
    [cell.textLabel setText:[(self.subjects)[indexPath.row] caption]]; 

    return cell; 
} 

這是完全一樣的應用程序所有其他表,但在這個特定的表,一個細胞總是潔白如下面的截圖看到。

這發生在我的iPhone 4S以及模擬器中。 我試圖從手機/模擬器刪除應用程序,重新啓動XCode,清除&重建解決方案,沒有任何改變。

screenshot of table with white cell

+0

什麼是Xcode調試告訴你在這一個實例? – zaph 2013-02-24 16:43:16

+0

一切似乎對我來說都很正常。右鍵點擊「Print description ...」將其寫入日誌:'>' 當擴展變量中的變量查看我得到以下: [截圖](http://imgur.com/ge4a33V) – cLar 2013-02-25 08:17:48

回答

0

我不知道如何或爲何這是的,但問題是某種相關setBackgroundColor:方法。如果我將其刪除,則問題仍然存在,但將其設置爲除[UIColor clearColor]之外的任何顏色都不會而是更改背景顏色,但單元格顯示正確。

相關問題