包含进度条的单元格的UITableView

时间:2013-03-24 17:22:34

标签: ios uitableview uiprogressview

我有一个表格视图,其中包含两种类型的单元格,一种是普通的字幕类型单元格,另一种是包含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

1 个答案:

答案 0 :(得分:0)

您应该只更新UIProgressView,而不是整个单元格。不需要'reloadRowsAtIndexPaths'。