0

We have a delegate method which will be called for approximately 20 times in a second. In the delegate method we are updating our UILabel which represents the counter like below mentioned code:

    - (void) counterUpdated:(NSString *) value
    {
        lblCounter.text = [NSString stringWithString:value];

        // [[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.5]];

        // [lblCounter setNeedDisplay];

    }

I read similar problems in stack overflow and I implemented the solutions over there and I checked with keeping [lblCounter setNeedDisplay]; method and [[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.5]]; after updating lblCounter, but it is not working well as expected.

Any pointers?

4

1 回答 1

0

尝试使用 Grand Central Dispatch 在主线程中运行它:

dispatch_async(dispatch_get_main_queue(), ^{
    lblCounter.text = value; 
});
于 2013-08-19T13:41:46.680 回答