2017-02-13 113 views
1

我目前在Swift应用程序上使用了一段时间。在之前的应用程序中,我没有任何问题,但是对于这个我有一个特殊的行为:计时器在模拟器上正常工作,但从不在真实设备上触发(10.0.2)。ios:计时器在模拟器中工作,但不在设备上

NSTimer.scheduledTimerWithTimeInterval(5.0, target:self, selector: #selector(AppDelegate.testTimer), userInfo: nil, repeats: true); 

这里是叫

func testTimer(){ 
    print("Timer called") 
} 

我看不出什么毛病此功能...我试着用同样的结果创建各种地方这个计时器....

编辑:我目前在雨燕2.3

+0

试穿迅速3' Timer.scheduledTimer(一个时间间隔:5.0,目标:自我,选择:选择器((AppDelegate.testTimer)),userInfo:nil,重复:false)' – iAviator

+0

它可能是ios 10.0.2中的错误。你的模拟器版本是什么? –

回答

0

编辑这只是斯威夫特3

的情况下10

我不能让你的代码在模拟器或设备的工作,但它的工作原理上都这样

let appDelegate = UIApplication.shared.delegate as! AppDelegate 
Timer.scheduledTimer(timeInterval: 1.0, target:appDelegate, selector: #selector(appDelegate.testTimer), userInfo: nil, repeats: true) 
+0

我在Siwft 2.3中,目前我正在迁移到3.0以查看是否存在影响,但没有相信它是根本原因...... – tomsoft

相关问题