开发者

how to run NSThread when app goes to background

I need to control the volume of device when app is in background so for this i use following code

 - (void)applicationDidEnterBackground:(UIApplication *)application
 {
back=1;

NSLog(@"Enter in the back");
float v=1.0f;

[NSThread detachNewThreadSelector:@selector(changeCounter) toTarget:self withObject:_viewController];

}

changeCo开发者_开发百科unter has infinite loop.But when i run the code and send the app to back.loop runs only for one time?


You need to request a background task from the UIApplication using beginBackgroundTaskWithExpirationHandler. There are examples in the Application Programming Guide (See the Completing a Finite-Length Task in the Background section).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜