我在 stackoverflow 上找到了很多关于NSTimer
在后台运行。
但是我没有找到任何解决方案。
在我的应用程序中,我在后台播放声音,并设置计时器在到达该时间时停止音乐。
所以我需要运行我的NSTimer
背景(指单击主页按钮并使 iPhone 休眠时)。
我怎样才能做到这一点?
// NSTimer run when app in background <br>
[[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:nil];
loop = [NSTimer scheduledTimerWithTimeInterval:0.25 target:self selector:@selector(Update) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:loop forMode:NSRunLoopCommonModes];
这就是你想要的吗?
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)