2014-10-11 78 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:总是返回一个有效的单元格,那么单元格永远不会是零,并且该代码永远不会执行。

因此,删除该条件,看看它是否工作。