Change UIButton Background Image more than once per second

Posted by beta.services on Stack Overflow See other posts from Stack Overflow or by beta.services
Published on 2010-04-01T07:04:54Z Indexed on 2010/04/03 20:43 UTC
Read the original article Hit count: 447

Filed under:
|
|
|
|

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?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about iphone-sdk