Quote:
Originally Posted by iph_s
This is not what I looking for. I know how to make random generator etc, but I don't know how to animate the process. I want to know how to animate the numbers in UILabel.
|
Record the current time to an NSTimeInterval instance variable:
NSTimeInterval startTime;
Code:
startTime = [NSDate timeintervalSinceReferenceDate];
Start an NSTimer that fires say, 4 times a second. Have that timer call a method, changeLabel:. Make your changeLabel method follow the signature for timer methods (it needs to have 1 parameter: the timer itself.)
In your changeLabel method, pick a random number, use it as an index into your array, and install the value at that index into your label.
Check to see if your time period (5 seconds) has elapsed. If it has, kill your timer.
Code:
if ([NSDate timeintervalSinceReferenceDate] - startTime >= 5)
[theTimer invalidate];
Are you asking how to do some sort of animation for updating your label? If so, what kind of animation?