开发者

NSTimer stop when app is hide?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜