<i id='4Lowc'><tr id='4Lowc'><dt id='4Lowc'><q id='4Lowc'><span id='4Lowc'><b id='4Lowc'><form id='4Lowc'><ins id='4Lowc'></ins><ul id='4Lowc'></ul><sub id='4Lowc'></sub></form><legend id='4Lowc'></legend><bdo id='4Lowc'><pre id='4Lowc'><center id='4Lowc'></center></pre></bdo></b><th id='4Lowc'></th></span></q></dt></tr></i><div id='4Lowc'><tfoot id='4Lowc'></tfoot><dl id='4Lowc'><fieldset id='4Lowc'></fieldset></dl></div>
    <legend id='4Lowc'><style id='4Lowc'><dir id='4Lowc'><q id='4Lowc'></q></dir></style></legend>

    • <bdo id='4Lowc'></bdo><ul id='4Lowc'></ul>
  1. <small id='4Lowc'></small><noframes id='4Lowc'>

      <tfoot id='4Lowc'></tfoot>
    1. 如何区分iOS5上的屏幕锁定和主页按钮按下?

      时间:2023-06-01

          <tbody id='yrDSr'></tbody>
          • <bdo id='yrDSr'></bdo><ul id='yrDSr'></ul>
              • <i id='yrDSr'><tr id='yrDSr'><dt id='yrDSr'><q id='yrDSr'><span id='yrDSr'><b id='yrDSr'><form id='yrDSr'><ins id='yrDSr'></ins><ul id='yrDSr'></ul><sub id='yrDSr'></sub></form><legend id='yrDSr'></legend><bdo id='yrDSr'><pre id='yrDSr'><center id='yrDSr'></center></pre></bdo></b><th id='yrDSr'></th></span></q></dt></tr></i><div id='yrDSr'><tfoot id='yrDSr'></tfoot><dl id='yrDSr'><fieldset id='yrDSr'></fieldset></dl></div>

              • <small id='yrDSr'></small><noframes id='yrDSr'>

              • <tfoot id='yrDSr'></tfoot>
                <legend id='yrDSr'><style id='yrDSr'><dir id='yrDSr'><q id='yrDSr'></q></dir></style></legend>
              • 本文介绍了如何区分iOS5上的屏幕锁定和主页按钮按下?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我正在开发一个在后台播放音频的 iPhone 应用.如果用户锁定屏幕,我希望音频继续播放,但如果他们决定切换到另一个应用程序(通过按下主页按钮),则暂停.

                I'm developing an iPhone app that plays audio in the background. I want the audio to keep playing if the user locks the screen, but pause if they decide to switch to another app (by pressing the home button).

                在 iOS 4 上没有问题,因为应用程序会在屏幕锁定时进入非活动状态,并且只有在按下主页按钮时才会移动到后台.在 iOS 5 上,当屏幕锁定时,应用程序现在也被移到后台,因此似乎不再可能区分这两种状态.这个问题有解决办法吗?

                On iOS 4 there was no problem because the app would go into the inactive state when the screen was locked and only be moved to the background if the home button was pressed. On iOS 5 when the screen is locked the app is now also moved into the background, so it seems it is no longer possible to tell the difference between the two states. Is there a solution to this problem?

                推荐答案

                您可以通过检查 UIApplicationapplicationState 属性来区分这两种情况.对于因锁屏而进入后台的应用程序,它将设置为 UIApplicationStateInactive,否则设置为 UIApplicationStateBackground.

                You can distinguish these two cases by checking the applicationState property of UIApplication. It will be set to UIApplicationStateInactive for an application that did enter background because of the lock screen, and to UIApplicationStateBackground otherwise.

                - (void)applicationDidEnterBackground:(UIApplication *)application
                {
                    UIApplicationState state = [application applicationState];
                    if (state == UIApplicationStateInactive) {
                        NSLog(@"Sent to background by locking screen");
                    } else if (state == UIApplicationStateBackground) {
                        NSLog(@"Sent to background by home button/switching to other app");
                    } 
                }
                

                这篇关于如何区分iOS5上的屏幕锁定和主页按钮按下?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:iOS:如何正确获取电池电量 下一篇:从 xcode 故事板可视化修改 UIToolbar

                相关文章

                最新文章

                1. <i id='1AhbI'><tr id='1AhbI'><dt id='1AhbI'><q id='1AhbI'><span id='1AhbI'><b id='1AhbI'><form id='1AhbI'><ins id='1AhbI'></ins><ul id='1AhbI'></ul><sub id='1AhbI'></sub></form><legend id='1AhbI'></legend><bdo id='1AhbI'><pre id='1AhbI'><center id='1AhbI'></center></pre></bdo></b><th id='1AhbI'></th></span></q></dt></tr></i><div id='1AhbI'><tfoot id='1AhbI'></tfoot><dl id='1AhbI'><fieldset id='1AhbI'></fieldset></dl></div>

                  <small id='1AhbI'></small><noframes id='1AhbI'>

                      <bdo id='1AhbI'></bdo><ul id='1AhbI'></ul>
                  1. <tfoot id='1AhbI'></tfoot>

                  2. <legend id='1AhbI'><style id='1AhbI'><dir id='1AhbI'><q id='1AhbI'></q></dir></style></legend>