Change UIButton Background Image more than once per second

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?


Have you tried to use setNeedsDisplay?

[button setNeedsDisplay];

how many images do you have? From what you gave us, you only have one image, so no duh the image won't change. Please post the code you have so we can further help you

Need Your Help

Ruby iterate through hash and compare value pairs

ruby hash iteration

My Ruby assignment is to iterate through a hash and return the key associated with the lowest value, without using any of the following methods:

ftp copy multiple files from unix

unix ftp

I want to copy files with a same prefix from one ftp server to local directory