开发者

NSTimer stop when app is hide?

开发者 https://www.devze.com 2023-03-13 10:58 出处:网络
I just want to know why a NSTimer is stoping when the application is hidden or \"Hide other\" in an other application ?

I just want to know why a NSTimer is stoping when the application is hidden or "Hide other" in an other application ? how can I re开发者_C百科medy this ?

Thanks


Maybe your timer is getting garbage collected or otherwise freed perhaps by the autorelease pool, and hence does not fire anymore.

Try doing this:

- (IBAction)recordCam1:(id)sender {
    myTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(recordFile1:) userInfo:Nil repeats:YES];
    [myTimer retain];
}

where myTimer is an instance variable in your class. See if that produces a different behaviour. If so, then you know the problem is to do with memory management.

0

精彩评论

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