Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to update a UILabel frequently?
    text
    copied!<p>I am currently working on a project where I request and parse multiple html sites in a controller. To give some feedback to the user I have created a second view, which gets displayed during processing of the data. It displays a status label and a progressbar. In my controller I have several points where I update my labels text. Unfortunately this works only sometimes. I guess thats because the label gets redrawn only once in a while and I try to do it probably more often than once a second.</p> <p><strong>It does not work to force a redraw with [label setNeedsDisplay];</strong></p> <p>I also made a <strong>thread</strong> which updates the labels text with the text of a global variable and also calls setNeedsDisplay on the label every second. But the results in the same. I only see certain changes, but not all. </p> <p>Everything is setup properly and the label never is nil. When I log my updateMethod everything seems allright. It just does not get displayed!</p> <p><strong>Cheers</strong></p> <p>Here is the code of my threads</p> <pre><code>- (void)startUpdateStatusThread{ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [self performSelectorOnMainThread:@selector(updateFrequently) withObject:nil waitUntilDone:NO]; [pool release]; } - (void)updateFrequently{ NSLog(@"updateFrequently: %@", currentStatus); test++; [self.statusLabel setText:[NSString stringWithFormat:@"%@ - %i", currentStatus, test]]; [self.statusLabel setNeedsDisplay]; [NSTimer scheduledTimerWithTimeInterval:0.0001 target:self selector:@selector(updateFrequently) userInfo:nil repeats:NO]; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload