4

我有一个在 iOS 13 之前的 Xcode 中生成的应用程序。该应用程序不支持多个窗口。虽然我们之前在 AppDelegate 上经历过奇怪的事情,但自 iOS 13 发布以来似乎更加奇怪,我希望看看其他人是否也经历过类似的事情。

具体来说,如果我进入多任务模式(在旧 iPhone 上双击主页按钮或从屏幕底部向上滑动并暂停显示所有后台应用程序窗口)然后重新进入我的应用程序,AppDelegate 似乎在调试时会正确触发,但如果我的应用程序中的音乐(通常在 applicationDidBecomeActive 中带回)中留给它自己的设备不会恢复。

更新:这似乎特别与音乐/声音有关——iOS 似乎正在接受任何播放器并将它们设置为零,不允许我阻止它们。iOS 似乎也忽略了 AppDelegate 中加载和播放音乐的指令。这里有什么故事?

我从这篇文章中了解到:iOS 13 中没有调用 App 委托方法,重要的是要么不支持多个窗口,要么在新的 Scene Delegate 中管理传统上在 App Delegate 中调用的指令;但是,它是否比我称其为 Scene Delegate 更重要?iOS 13 中的这种行为是否有其他解释或我可以使用的其他解决方法?

AppDelegate 中的摘要代码:

func applicationDidBecomeActive(_ application: UIApplication)
{
...
// Check to see if there is secondary audio playing; if true, stop our audio and eliminate all queued up music
        if AVAudioSession.sharedInstance().secondaryAudioShouldBeSilencedHint
        {
            AssetsSounds.sharedInstance.bgmGamePlayer?.stop()
            AssetsSounds.sharedInstance.bgmGamePlayer = nil
            needToPlayGameMusic = false
            AssetsSounds.sharedInstance.bgmTitlePlayer?.stop()
            AssetsSounds.sharedInstance.bgmTitlePlayer = nil
            needToPlayTitleMusic = false
            ...
        }
        // if no secondary music, check to see if we need to restart any of the bgm players
        else if needToPlayGameMusic || needToPlayTitleMusic || needToPlayBonusLoop || needToPlayBonusLeadIn || needToPlayFiveMovesLeft
        {
            // play background music if it needs to be played
            if needToPlayTitleMusic
            {
                AssetsSounds.sharedInstance.bgmTitlePlayer?.play()
                needToPlayTitleMusic = false
            }

            // play game music if it needs to be played
            else if needToPlayGameMusic
            {
                AssetsSounds.sharedInstance.bgmGamePlayer?.play()
                needToPlayGameMusic = false
            }
            ...


    } // end else if
...
}
4

0 回答 0