UILabel Dynamic Update

I have a question about UILabels. I'm not even sure if this is the right way to clear this, but I'm trying to update the UILabel to display two numbers from 0 to 24, and then go back to zero and display the numeric number again. The trick is, he needs to update UILabel every 1/24 second. Here is the code that I still have ...

-(void)viewDidLoad {
fpsTimer = [NSTimer scheduledTimerWithTimeInterval: .01 target: self selector: @selector(updateFpsDisplay) userInfo: nil repeats: YES];
}

- (void)updateFpsDisplay {
    for (int i=0; i<100; i++) {
        NSLog(@"%d", i%24);
        [timecodeFrameLabel setText:[NSString stringWithFormat:@"0%d", i%24]];
    }
}

This code successfully prints numbers 1-24 in a loop in the console at runtime. However, a UILabel named "timecodeFrameLabel" just shows 03 and does not change.

Any suggestions?

0
source share
1 answer

. -, -updateFpsDisplay 0 99, . , . , 0,01 100 , . , , , . - i (, ), , .

- (void)updateFpsDisplay {
    // the ivar frameCount replaces i
    [timecodeFrameLabel setText:[NSString stringWithFormat:@"0%d", frameCount%24]];
}

, 100 24. 99% 24 == 3, "3". , , -updateFpsDisplay, frameCount reset , 0, :

if (frameCount % 24 == 0) {
    frameCount = 0;
}

frameCount , , - .

+5

All Articles