相关疑难解决方法(0)

NSTimer在背景上工作

我根本不明白它,但NSTimer在我的应用程序肯定是在后台运行.我有一个NSLog由计时器运行的mehod,它在后台进行记录.它位于带有iOS 4.2.1的iPhone 4上.我在Info.plist中声明了位置背景支持.

我在这里和其他地方阅读了文档和许多讨论,这是不可能的.这是一个iOS错误吗?还是没有文档的功能?我不想使用它并在不久的将来发现,例如随着iOS 4.3的出现,Apple默默地"修复"它并且应用程序无法正常工作.

有人知道更多吗?

cocoa-touch background nstimer runloop ios

17
推荐指数
2
解决办法
2万
查看次数

应用程序进入后台时如何保留NSTimer?

我在这里因为没有找到任何解决方案我的问题:(

我正在做一个简单的应用程序,我必须将(通过套接字)一些信息发送到服务器(如GPS l/L,精度,电池电量等).

当应用程序在前台时,当前代码工作正常.

myTimer = [NSTimer scheduledTimerWithTimeInterval: 2.0 target:self
                                                  selector: @selector(sendPosToServer:) userInfo:nil repeats: YES];
myTimer2 = [NSTimer scheduledTimerWithTimeInterval: 3.0 target:self
                                                  selector: @selector(sendBatteryToServer:) userInfo:nil repeats: YES];
myTimer3 = [NSTimer scheduledTimerWithTimeInterval: 5.0 target:self
                                                  selector: @selector(sendResToServer:) userInfo:nil repeats: YES];
myTimer4 = [NSTimer scheduledTimerWithTimeInterval: 5.0 target:self
                                                  selector: @selector(sendQResToServer:) userInfo:nil repeats: YES];
myTimer5 = [NSTimer scheduledTimerWithTimeInterval: 3.0 target:self
                                                   selector: @selector(sendPrecisionToServer:) userInfo:nil repeats: YES];
Run Code Online (Sandbox Code Playgroud)

调用所有方法.

但是当应用程序进入后台时,所有计时器都无效...我已经读过iOS自动停止计时器..我正在寻找一种方法来调用方法并在应用程序处于后台时发送数据.

我需要你的帮助 :)

谢谢大家 !!

background scheduling foreground nstimer ios

8
推荐指数
2
解决办法
2万
查看次数