【问题标题】:Tableview reloadRowsAtIndexPaths gain to 50% CPU Memory?Tableview reloadRowsAtIndexPaths 获得 50% CPU 内存?
【发布时间】:2015-07-05 10:11:31
【问题描述】:

我有一个问题,我有一个 UITableViewController,当视图出现时,我会异步执行一些计算,这会导致更新表中的特定行。

在 cellStartEditing 函数中,我计算了需要更新的必要行,如下所示:

-(void) cellStartEditing:(templateRow *) row{
    int Cellowid= row.rowId;
    [arrQuestions removeObjectAtIndex:CellRowid];
    [arrQuestions insertObject:row atIndex:CellRowid];
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow: inSection:0];
    [tvQuestion reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
}

当时 reloadRowsAtIndexPaths 动画获得 50% CPU 内存?

【问题讨论】:

  • 这个方法是不是不小心被多次调用了?
  • 只有一次单击单元格索引时..
  • 如果你提供cellForRowAtIndexPath方法代码,那就更清楚了,为什么会这样。
  • [tvQuestion cellForRowAtIndexPath:indexPath];但表不会在索引处重新加载。

标签: ios iphone uitableview uiviewanimation nsindexpath


【解决方案1】:

在重新加载行之前通知 tableview 更新如下:

[tvQuestion beginUpdates];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow: inSection:0];
[tvQuestion reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]
[tvQuestion endUpdates];

【讨论】:

  • 如果我必须使用 200 行而不是获得内存,但在 200 - 1000 动画之后获得内存
  • 希望你使用 Reusable cells ,这会释放内存。
  • customeCellAnswer *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];但是哪种类型会释放内存?
猜你喜欢
  • 2011-09-01
  • 2014-07-07
  • 1970-01-01
  • 2018-06-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-03-06
相关资源
最近更新 更多