-4
我的问题是,每当用户点击一个按钮,UITableviewcell
文字颜色需要改变。这是我的代码UITableview不重装和刷新
- (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];
仍然没有用...
你遗漏了一些非常重要的信息,比如你崩溃时得到什么样的错误,崩溃了什么。 – dandan78
没有显示在控制台..但错误是0x121209b:movl 8(%edx),%edi - - EXC_BAD_ACCESS – Joker
我建议在你的按钮动作和'tableView:cellForRowAtIndexPath:'找出断点在哪里崩溃发生。 – dandan78