-4

我的问题是每当用户点击按钮时,UITableviewcell文本颜色都需要更改。这是我的代码

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath                                                                               *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    CustomCell *cell=(CustomCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if(cell==nil){
        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
        for(id currentObject in topLevelObjects){
            if([currentObject isKindOfClass:[UITableViewCell class]]){
                cell = (CustomCell *) currentObject;
                break;
            }
        }
    }
    if(one == YES)
    {
        cell.dayLabel.textColor = [UIColor blackColor];
        cell.imageLabel.textColor = [UIColor blackColor];
        cell.high.textColor = [UIColor blackColor];
        cell.low.textColor = [UIColor blackColor];
    }
    else if(two == YES)
    {
        cell.dayLabel.textColor = [UIColor whiteColor];
        cell.imageLabel.textColor = [UIColor whiteColor];
        cell.high.textColor = [UIColor whiteColor];
        cell.low.textColor = [UIColor whiteColor];
    }
}

我在按钮操作中重新加载了,但是当您重新加载时它崩溃了。我试[tableview setNeedsToDisplay];了还是没用...

4

1 回答 1

3

tableView:cellForRowAtIndexPath:没有返回 UITableViewCell。

于 2012-09-12T13:38:07.853 回答