0

当我点击 Home Button 时,应用程序调用AppDelegatefunction applicationDidEnterBackground,然后applicationWillEnterForeground我回到它。

我使用以下代码:

    func applicationDidEnterBackground(application: UIApplication) {
        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.

         mainScene.view?.paused = true
    }

    func applicationWillEnterForeground(application: UIApplication) {
        // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.

        mainScene.view?.paused = false
    }

它工作正常。我可以暂停应用程序并在需要时恢复它。但是,如果我在我的应用程序中当前正在播放声音(如“枪声”或“硬币落下”等)时点击主页按钮,SKAction.playSoundFileNamed然后尝试恢复应用程序,它会崩溃。我可以正常恢复它的唯一方法是当我点击主页按钮时没有任何活动声音。

任何解决方法?

4

0 回答 0