なぜappDidFinishLaunchingに配置するとこれが繰り返されませんか?NSTimerがAppDelegateから繰り返さない
self.ti = [NSTimer timerWithTimeInterval:10. target:self selector:@selector(bounce:) userInfo:nil repeats:YES];
[self.ti fire];
多くのおかげ
ジュール
なぜappDidFinishLaunchingに配置するとこれが繰り返されませんか?NSTimerがAppDelegateから繰り返さない
self.ti = [NSTimer timerWithTimeInterval:10. target:self selector:@selector(bounce:) userInfo:nil repeats:YES];
[self.ti fire];
多くのおかげ
ジュール
は、私はあなたのbounce
が間違った署名を持っていると思います。それはあなたがこの方法をスケジュールするselector(bounce:)
を使用する必要があります
- (void)bounce:(NSTimer*)theTimer {
NSLog(@"Here...");
}
でなければなりません。またtimerWithTimeInterval
の代わりにscheduledTimerWithTimeInterval
を呼び出すする必要があります。それが役立つ場合
self.ti = [NSTimer
scheduledTimerWithTimeInterval:10.
target:self
selector:@selector(bounce:)
userInfo:nil
repeats:YES];
あなたは正しかった、私は必要:私のセレクタで、ありがとう:) – Jules
私はわからないんだけど、scheduledTimerWithTimeInterval
方法を使用してみてください。例:
self.ti = [NSTimer scheduledTimerWithTimeInterval:10. target:self selector:@selector(bounce) userInfo:nil repeats:YES];
は 'バウンス' 内のコードは何ですか、それは
これも、感謝:) – Jules
を役に立てば幸い?また、あなたはどのように 'ティ'を設定していますか? – Jeremy1026
はバウンスしています。私は単に、それが呼び出されているかどうかを見るために瞬間的にロギングしています。ティは私のヘッダ(強く非原子的)の中のプロパティであり合成されています。一度だけ繰り返すのではなく、コードは一度も発射されませんか?再び多くのおかげです – Jules