I want to create on slide show in my iphone application which open if the user don't touch the screen for 30 second , for that i have made on method which reset the time when user开发者_运维技巧 touch the screen .
I have used nstimer class to handle timer event .
my problem is that even if invalidating the timer the event has been fire after the time interval my reset timer method is as per below
-(void) resetTimer {
if(timerForScreenSaver != nil)
{
timerForScreenSaver = nil;
[timerForScreenSaver invalidate];
NSLog(@"timer is invalidate %@ ",timerForScreenSaver);
}
timerForScreenSaver = [NSTimer scheduledTimerWithTimeInterval:15.0 target:self selector:@selector(showScreenSaver) userInfo:nil repeats:NO];
NSLog(@"timer is set");
}
can any one help me to reset the timer .
Thanks and Regard
Kunal PatelSwap the following two lines:
timerForScreenSaver = nil;
[timerForScreenSaver invalidate];
You make your timer nil so invalidating has no effect
精彩评论