2014-10-11 77 views
0

我莫名其妙地具有如設置文本顏色與格文本顏色

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier [email protected]"Cell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 
    if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
     cell.textLabel.textColor=[UIColor whiteColor]; 
     cell.detailTextLabel.textColor=[UIColor lightTextColor]; 
     cell.backgroundColor=[UIColor clearColor]; 

    } 
    NSArray *array=[[NSArray alloc]initWithArray:messagingArrayToBeDisplayedInTableWhenCalloutTapped[indexPath.row]]; 

    cell.textLabel.textColor=[UIColor whiteColor]; 
    cell.detailTextLabel.textColor=[UIColor lightTextColor]; 
    cell.backgroundColor=[UIColor clearColor]; 
    cell.textLabel.text=[array objectAtIndex:0]; 
    cell.detailTextLabel.text=[array objectAtIndex:1]; 


    return cell; 
} 

背景色的作品,但文字顏色設置爲whiteColor簡單的東西的問題沒有任何作用使標題和副標題是默認灰色的顏色。我嘗試在原型單元格中更改顏色,但這也不起作用。有人能夠提出解決方案嗎?在此先感謝:)

+0

你在使用故事板嗎?如果是這樣,你也可以在那裏改變它。 – Viper 2014-10-11 22:28:14

+0

您可以刪除6行代碼,因爲'cell'是_never_ nil。 – matt 2014-10-11 22:31:13

+0

我已經更改屬性檢查器中的標籤顏色,但沒有任何反應 – RodMatveev 2014-10-11 22:37:54

回答

0

dequeueReusableCellWithIdentifier:forIndexPath:總是返回一個有效的單元格,那麼單元格永遠不會是零,並且該代碼永遠不會執行。

因此,刪除該條件,看看它是否工作。