0

这是我的代码

- (void)updateCounterImage:(NSTimer *)theTimer
{
    static int count = 0;
    count += 1;
    int crb = 6 - count;
    UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"ipad_game_timer_digit-%d.png", crb]];

    if ( count == 6)
        [timer release];

    [countTime setImage:image];
}


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [super viewDidLoad];
    correctLevel.hidden = YES;
    incorrectLevel.hidden = YES;
    incorrectAnswer.hidden = YES;
    correctAnswer.hidden = YES;
    timer = [NSTimer scheduledTimerWithTimeInterval:1.0f
                                     target:self
                                   selector:@selector(updateCounterImage:)
                                   userInfo:nil
                                    repeats:NO];

}

#import <UIKit/UIKit.h>

@interface GameController : UIViewController
{

    IBOutlet UIImageView *countTime;
    NSTimer *timer;
}


@end

问题是我的 imageView 没有改变它的图像。

4

2 回答 2

1

您已设置repeatsNOscheduledTimerWithTimeInterval这意味着计时器只会滴答一次。

于 2012-09-07T14:48:34.483 回答
1

你应该写

timer = [NSTimer scheduledTimerWithTimeInterval:1.0f
                                 target:self
                               selector:@selector(updateCounterImage:)
                               userInfo:nil
                                repeats:YES];
于 2012-09-07T14:51:34.097 回答