可能重复:
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];
}
所以,请建议我这样做......