我有一个包含 2 种单元格的表格视图,一个普通的字幕类型单元格和一个包含 progressView 的自定义单元格。当委托调用完成百分比方法时,该单元格(表格视图中只有一个单元格可以有进度条)需要更新进度视图。
这是代码:
- (void)finishedPercent
{
percent += 0.01;
// reload cell
//NSLog(@"received percent");
[self.tableView beginUpdates];
[self.tableView reloadRowsAtIndexPaths:@[indexPathOfRunningFormula] withRowAnimation:UITableViewRowAnimationNone];
[self.tableView endUpdates];
}
它更新非常,偶尔从接近零跳跃到 90% 或类似的东西。
这是输出的一部分
2013-03-24 19:15:53.285 FutureSight[5455:12e07] *** Assertion failure in -[_UITableViewUpdateSupport _setupAnimationsForNewlyInsertedCells], /SourceCache/UIKit_Sim/UIKit-2380.17/UITableViewSupport.m:1145
2013-03-24 19:16:03.850 FutureSight[5455:16003] percent done
2013-03-24 19:16:04.325 FutureSight[5455:16103] percent done
2013-03-24 19:16:04.372 FutureSight[5455:16103] percent done
2013-03-24 19:16:04.478 FutureSight[5455:16003] *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-2380.17/UITableView.m:909
2013-03-24 19:16:04.477 FutureSight[5455:12e07] percent done
2013-03-24 19:16:07.727 FutureSight[5455:16103] percent done
2013-03-24 19:16:07.790 FutureSight[5455:16103] percent done
2013-03-24 19:16:07.801 FutureSight[5455:16003] *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-2380.17/UITableView.m:909
问题是什么?
将代码更改为
- (void)finishedPercent
{
percent += 0.01;
PSFormulaProgressCell *cell = (PSFormulaProgressCell *)[self.tableView cellForRowAtIndexPath:indexPathOfRunningFormula];
cell.progress.progress = percent;
// // reload cell
NSLog(@"received percent");
// [self.tableView beginUpdates];
// [self.tableView reloadRowsAtIndexPaths:@[indexPathOfRunningFormula] withRowAnimation:UITableViewRowAnimationNone];
// [self.tableView endUpdates];
}
仍然不起作用,它显示进度条但更新填充它..
FutureSight(6368,0xb0115000) malloc: *** error for object 0xff39fd0: double free
*** set a breakpoint in malloc_error_break to debug
FutureSight(6368,0xb0365000) malloc: *** error for object 0xff392c0: double free
*** set a breakpoint in malloc_error_break to debug
2013-03-24 20:27:13.188 FutureSight[6368:12e03] received percent
2013-03-24 20:27:13.189 FutureSight[6368:15503] received percent
2013-03-24 20:27:13.252 FutureSight[6368:15503] received percent
2013-03-24 20:27:13.321 FutureSight[6368:15407] received percent
2013-03-24 20:27:13.383 FutureSight[6368:12e03] received percent
2013-03-24 20:27:13.444 FutureSight[6368:15407] received percent
2013-03-24 20:27:13.444 FutureSight[6368:12e03] received percent
2013-03-24 20:27:13.509 FutureSight[6368:12e03] received percent
2013-03-24 20:27:13.509 FutureSight[6368:15407] received percent
2013-03-24 20:27:13.579 FutureSight[6368:15503] received percent
FutureSight(6368,0xb0261000) malloc: *** error for object 0x7a0c400: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
2013-03-24 20:27:13.846 FutureSight[6368:15407] received percent
2013-03-24 20:27:13.846 FutureSight[6368:12603] received percent