2

appDidFinishLaunchingに配置したときに、これが繰り返されないのはなぜですか?

self.ti = [NSTimer timerWithTimeInterval:10. target:self selector:@selector(bounce:) userInfo:nil repeats:YES];
[self.ti fire];

どうもありがとう

ジュール

4

2 に答える 2

4

それが役立つかどうかはわかりませんが、scheduledTimerWithTimeIntervalメソッドを使用してみてください。例:

self.ti = [NSTimer scheduledTimerWithTimeInterval:10. target:self selector:@selector(bounce) userInfo:nil repeats:YES];

それが役に立てば幸い

于 2012-05-11T14:46:35.103 に答える
4

bounceあなたの署名は間違っていると思います。そのはず

- (void)bounce:(NSTimer*)theTimer {
    NSLog(@"Here...");
}

selector(bounce:)このメソッドのスケジュールにはを使用する必要があります。scheduledTimerWithTimeIntervalまた、次の代わりに呼び出す必要がありますtimerWithTimeInterval

self.ti = [NSTimer
    scheduledTimerWithTimeInterval:10.
                            target:self
                          selector:@selector(bounce:)
                          userInfo:nil
                           repeats:YES];
于 2012-05-11T14:42:22.953 に答える