开发者

Slide show effect in iphone

开发者 https://www.devze.com 2023-01-16 19:46 出处:网络
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开发者_运维技巧 touc

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 Patel


Swap the following two lines:

timerForScreenSaver = nil;
[timerForScreenSaver invalidate];

You make your timer nil so invalidating has no effect

0

精彩评论

暂无评论...
验证码 换一张
取 消