选择的NSTimer得到保持在后台甚至称 [英] NSTimer selector keeps getting called even in the background

查看:102
本文介绍了选择的NSTimer得到保持在后台甚至称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我有一个的NSTimer 被设置为来电选择器每秒:

So, I have an NSTimer that is set to call a selector every second:

        timer = [NSTimer scheduledTimerWithTimeInterval:1.0f
                                                 target:self
                                               selector:@selector(TimerSelector:)
                                                userInfo:nil
                                                repeats:YES ];

这是一切优秀的,但自从我更新到iOS 8,我注意到,这个选择状态越来越称为应用程序进入后台后还是一样。我认为这最终会停止运转,因为我相信iOS应用程序是不允许在没有原因的后台运行,但选择继续得到调用。我试图保持应用程序上模拟内存警告,而是选择继续得到要求6小时以上。

This is all fine, but ever since I updated to iOS 8, I've noticed that this selector keeps getting called even after the application goes to the background. I thought that it would eventually stop running, as I believe an iOS application isn't allowed run in the background without a reason, but the selector kept getting called. I tried keeping the application on and simulating memory warnings, but the selector kept getting called for over 6 hours.

此行​​为只展出的iOS 8和iOS的不7.这是正常的吗?难道iOS的8带来新的东西,我不知道的?

This behavior was only exhibited in iOS 8 and not iOS 7. Is this normal? Did iOS 8 bring something new I'm not aware of?

推荐答案

这听起来像它可能在iOS的8一个令人兴奋和有趣的变化,但恐怕这只是在模拟器中的错误。有没有计时器继续在后台的设备的,这是所有真正的问题上运行的证据。

It sounds like it might be an exciting and interesting change in iOS 8, but I'm afraid that it is just a bug in the simulator. There's no evidence of timers continuing to run in the background on the device, which is all that really matters.

在设备上的情况的 的是,除非你的应用程序有一些其他的原因,在后台运行,计时器,而您的应用程序在后台运行,当你的应用程序来暂停,并恢复前景中,正如在previous系统

The situation on the device is that, unless your app has some other reason to run in the background, the timer is paused while your app is in the background, and resumes when your app comes to the foreground, just as in the previous system.

在了iOS 8的模拟的,但是,有一个著名的bug(苹果展示它的知名度在十一月和2014年12月开发论坛帖):任务继续运行并没有中止时该应用程序是后台运行。不加理会!该模拟器只是一个模拟器。做了设备上的实际测试。

In the iOS 8 simulator, however, there's a well-known bug (Apple shows awareness of it in Dev Forums posts from November and December 2014): tasks continue to run and are not suspended when the app is backgrounded. Take no notice! The simulator is just a simulator. Do your real testing on a device.

这篇关于选择的NSTimer得到保持在后台甚至称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆