可能重复:
NSTimer doesn't stop
如何停止/使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];
}
所以,请建议我这样做......
答案 0 :(得分:3)
我遇到了同样的问题。我猜你已经把它作为属性非原子,保留?
请这样做:
[self.autoscrollTimer invalidate];
感谢。