如何停止/使 NSTimer 失效
可能的重复:
NSTimer 不会停止
如何停止/使 NSTimer 失效?
下面是代码:
- (void)autoscrollTimerFired:(NSTimer*)timer {
NSLog(@"Each & Every Time this MEthods is called Even if I try to invalidate it in viewDidDisappear ");
}
- (void)viewWillAppear:(BOOL)animated{
if (autoscrollTimer == nil) {
autoscrollTimer = [NSTimer scheduledTimerWithTimeInterval:(35.0/1000.0)
target:self
selector:@selector(autoscrollTimerFired:)
userInfo:nil
repeats:YES]; // To repeat this thread it's as per my requirement
}
}
-(void) viewWillDisappear:(BOOL)animated {
[autoscrollTimer invalidate];
}
所以,请建议我这样做......
Possible Duplicate:
NSTimer doesn't stop
How can I stop / invalidate a NSTimer??
Below is the code:
- (void)autoscrollTimerFired:(NSTimer*)timer {
NSLog(@"Each & Every Time this MEthods is called Even if I try to invalidate it in viewDidDisappear ");
}
- (void)viewWillAppear:(BOOL)animated{
if (autoscrollTimer == nil) {
autoscrollTimer = [NSTimer scheduledTimerWithTimeInterval:(35.0/1000.0)
target:self
selector:@selector(autoscrollTimerFired:)
userInfo:nil
repeats:YES]; // To repeat this thread it's as per my requirement
}
}
-(void) viewWillDisappear:(BOOL)animated {
[autoscrollTimer invalidate];
}
So,please suggest me to do this ...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也有同样的问题。我猜你已经把它作为非原子属性了,保留吗?
请这样做:
谢谢。
I had the same problem. I guess you have made it as property nonatomic, retain?
Please do this:
Thanks.