【问题标题】:UITableview not reloading and refreshingUITableview 不重新加载和刷新
【发布时间】:2012-09-12 13:18:25
【问题描述】:

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

【问题讨论】:

  • 你遗漏了一些非常重要的信息,例如当它崩溃时你会得到什么样的错误,以及它在哪一行崩溃。
  • 控制台中没有显示任何内容.. 但错误是 0x121209b: movl 8(%edx), %edi - -- EXC_BAD_ACCESS
  • 我建议在您的按钮操作和tableView:cellForRowAtIndexPath: 中放置一个断点以找出崩溃发生的位置。
  • 当我们重新加载 tableview 时它崩溃了
  • 确定它们是布尔值。但是你如何设置它们?

标签: ios objective-c uitableview cocoa-touch


【解决方案1】:

您的 tableView:cellForRowAtIndexPath: 没有返回 UITableViewCell。

【讨论】:

    猜你喜欢
    • 2014-10-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-18
    • 2011-01-01
    • 2019-06-10
    • 2011-08-26
    相关资源
    最近更新 更多