【问题标题】:Leak when I load custom UITableViewCells from Xib files?当我从 Xib 文件加载自定义 UITableViewCells 时泄漏?
【发布时间】:2012-02-12 09:24:19
【问题描述】:

我在以下代码中出现泄漏。泄漏百分比@行尾。谁能告诉我是什么问题。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

coustomMessage *cell = (coustomMessage *)[tableView dequeueReusableCellWithIdentifier:@"coustomMessage"];
if (cell == nil) {
    NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"coustomMessage" owner:self options:nil]; (93.1%)
    cell = [topLevelObjects objectAtIndex:0];
}

cell.nameLable.text = [self.nameArray objectAtIndex:indexPath.row]; (3.4%)
cell.messageStatusLable.text = [[self.endPointCountArray objectAtIndex:indexPath.row] stringValue]; (3.4%)

return cell;}

【问题讨论】:

    标签: iphone objective-c ios performance instruments


    【解决方案1】:

    太棒了!我遇到了完全相同的问题,我在 XIB 中拼错了标识符,并且由于我们重新创建的单元格没有被重新使用而导致大量泄漏。谢谢!

    【讨论】:

      【解决方案2】:

      您确定您在 XIB 文件中设置的“标识符”属性与您在代码中使用的名称相同(使用:dequeueReusableCellWithIdentifier:@"coustomMessage")?

      【讨论】:

      • 我怎么错过了。谢谢@meronix
      • @Amit:它只是发生了(对我来说也是)......你觉得我是怎么理解的?
      猜你喜欢
      • 2010-10-07
      • 2017-10-01
      • 2019-11-26
      • 2015-02-03
      • 2017-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多