My problem is whenever the user taps a button, the UITableviewcell text colors needs to change. This is my code
- (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];
}
}
I reloaded in the button action, but it’s crashing when you reload.
I tried [tableview setNeedsToDisplay]; still no use…
your
tableView:cellForRowAtIndexPath:is not returning a UITableViewCell.