0

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
Cœur
  • 37,241
  • 25
  • 195
  • 267
user1028028
  • 6,323
  • 9
  • 34
  • 59
  • 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 Mar 24 '13 at 17:34
  • apparently directing updating the progress bar doesn't work either – user1028028 Mar 25 '13 at 01:58
  • 1
    You haven't confirmed whether `finishedPercent` is called on the main thread or not. – rmaddy Mar 25 '13 at 02:00
  • Hmm... that seems to be the problem .. it wasn't called on the main thread ... it works now – user1028028 Mar 26 '13 at 13:35

1 Answers1

0

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

Matt
  • 2,391
  • 2
  • 17
  • 18
  • Have you tried [cell.progress setNeedsDisplay] after updating it? – Matt Mar 24 '13 at 18:34
  • That's strange. Where is your finishedPercent method called? – Matt Mar 24 '13 at 22:38
  • It's called from an object that this one is a delegate to... the "received percent" means that this function is being called ... however the progress view is not setting the new percent ... – user1028028 Mar 25 '13 at 01:58