Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/121.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 当applicationWillResignActive时暂停AppDelegate中的计时器_Ios_Swift - Fatal编程技术网

Ios 当applicationWillResignActive时暂停AppDelegate中的计时器

Ios 当applicationWillResignActive时暂停AppDelegate中的计时器,ios,swift,Ios,Swift,我在GameSecene.swift文件中有一个计时器,可以启动/重置,但当在通话过程中最小化应用程序或按下home(主页)按钮时,它会继续运行。当应用程序再次激活时,如何停止计时器并继续计时 if name == "player" { // first touch if playerFirstTouch { print("New Game") NSTimer.scheduledTimerWithTimeInter

我在GameSecene.swift文件中有一个计时器,可以启动/重置,但当在通话过程中最小化应用程序或按下home(主页)按钮时,它会继续运行。当应用程序再次激活时,如何停止计时器并继续计时

if name == "player" {
        // first touch
        if playerFirstTouch {
            print("New Game")

            NSTimer.scheduledTimerWithTimeInterval(0.1, target: self, selector: "printDuration:", userInfo: NSDate(), repeats: true)
        }
}

应用程序标识符背景中停止此计时器,或在应用程序内委托中停止此计时器

-(无效)视图将在加载SKView的ViewController中消失