[英]NSTimer not repeating from AppDelegate
放在appDidFinishLaunching中时为什么不重复?
self.ti = [NSTimer timerWithTimeInterval:10. target:self selector:@selector(bounce:) userInfo:nil repeats:YES];
[self.ti fire];
非常感谢
儒勒
我认为你的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];
我不确定它是否有用,但尝试使用scheduledTimerWithTimeInterval
方法。 一个例子:
self.ti = [NSTimer scheduledTimerWithTimeInterval:10. target:self selector:@selector(bounce) userInfo:nil repeats:YES];
希望能帮助到你
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.