Change UIButton Background Image more than once per second
- by beta.services
I am currently working with the iPhone SDK.
I have a NSTimer that changes the background image of a UIButton.
Once this is complete, it will trigger the same action again (reset the NSTimer) for a predetermined number of times.
My problem is that if my NSTimer is set to execute more than once per second. (0.75, say) The background image wont change.
I am using NSLog to check that the event fires. But the button image will just remain in its original state.
Is there any way to change the background image more often than once per second?
This is my timer :
[NSTimer scheduledTimerWithTimeInterval: tmpLvlSpeed
target: self
selector: @selector(simPressRed:)
userInfo: nil
repeats: NO];
And the code to change the image:
[btnRed setImage:[UIImage imageNamed:@"btn_red.png"] forState:UIControlStateNormal];
if tmpLvlSpeed is less than 1.0, the button image will never change. Even though the simPressRed function will still fire.
Any clues? Is there an update cycle I can modify?