how to quit (exit) an app in iPhone4 sdk

后端 未结 4 990
星月不相逢
星月不相逢 2020-12-18 14:35

How can I quit iPhone4 app? When I use exit(0) the app goes in the background. I want to quit the app instead of sending it to the background.

相关标签:
4条回答
  • 2020-12-18 15:18

    iPhone apps shouldn't have a quit button. The user quits by pressing the main button.

    From Apple's docs: (http://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/MobileHIG.pdf)

    People quit an iPhone application by opening a different application. In particular, note that people don’t tap an application close button or choose Quit from a menu. In iOS 4.0 and later, and on certain devices, the quitting application moves to a suspended state in the background. All iPhone applications should:

    • Be prepared to quit at any time. Therefore, save user data as soon as possible and as often as reasonable.
    • Save the current state when stopping, at the finest level of detail possible. For example, if your application displays scrolling data, save the current scroll position.

    iPhone applications should never quit programmatically because doing so looks like a crash to the user. There may be times, however, when external circumstances prevent your application from functioning as intended. The best way to handle this is to display an attractive screen that describes the problem and suggests how users can correct it. This helps users in two ways:

    • It provides feedback that reassures users that there’s nothing wrong with your application
    • It puts users in control, letting them decide whether they want to take corrective action and continue using your application or press the Home button and open a different application
    0 讨论(0)
  • 2020-12-18 15:19

    Set UIApplicationExitsOnSuspend in your application's plist. This will cause the app not to go into the background under iOS4 when the user switches to another app.

    Then have your app send an openURL: message to Safari when your app wants to exit. When Safari launches, your app will be terminated (by honoring the UIApplicationExitsOnSuspend plist key).

    If you point the Safari URL at a web page explaining why your app just stopped running, the user might be less likely to give it a 1-star rating.

    Note that this procedure may or may not follow Apple's recommendations, but it does stay within legal public API use (e.g. even some of Apple's example apps launch Safari).

    0 讨论(0)
  • 2020-12-18 15:19

    after that I put everything I had said I put this and it worked

    - (Void) applicationDidEnterBackground: (UIApplication *) application
    {
          exit (0);
    }
    

    comes completely out of the application

    0 讨论(0)
  • 2020-12-18 15:20

    in app delegate there is method call applicationDidEnterBackground

    call the exit(0)

    0 讨论(0)
提交回复
热议问题