我的问题是每当用户点击按钮时,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];
了还是没用...