0
votes

I have a table View with 2 types of cells a normal subtitle type cell and a custom cell that contains a progressView. When a delegate calls the finished percent method that cell (only one cell in the table view can have the progress bar) needs to update the progress view.

Here is the code:

- (void)finishedPercent
{
    percent += 0.01;

    // reload cell
    //NSLog(@"received percent");
    [self.tableView beginUpdates];
    [self.tableView reloadRowsAtIndexPaths:@[indexPathOfRunningFormula] withRowAnimation:UITableViewRowAnimationNone];
    [self.tableView endUpdates];
}

It updates very , sporadically jumping from near zero to 90% or something like that.

This is part of the output

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

What is the problem?

Changed code to

- (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];
}

Still doesn't work , it shows the progress bar but newer fills it..

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
Why are you reloading the row? Why not directly update the progress bar? Also, make sure this finishedPercent method is being called in the main thread and not a background thread.rmaddy
apparently directing updating the progress bar doesn't work eitheruser1028028
You haven't confirmed whether finishedPercent is called on the main thread or not.rmaddy
Hmm... that seems to be the problem .. it wasn't called on the main thread ... it works nowuser1028028

1 Answers

0
votes

You should only update the UIProgressView, not the whole cell. No need for 'reloadRowsAtIndexPaths'.