3

I would like to close an iPad application as a result of clicking on a UIButton. However, I have not seen how to do this in the Apple documentation.

What call needs to be made to close an app?

Thanks.

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
John
  • 10,839
  • 8
  • 26
  • 31
  • I wanted to show an EULA, and if the user disagrees with it, then I wanted to close the app. Seemed like an appropriate action if disagreed upon. – John Jan 10 '11 at 18:03
  • 2
    No. In this case you should enable forward/next button only if user accepts the EULA. If not then the user have no way other than to press the home button and terminate the app. That means user will either accept or terminate the app by pressing home. You SHOULD not add an exit button for this. Check the answers for possible problems with exit button. – taskinoor Jan 10 '11 at 18:07
  • 3
    Also, Apple will not accept an application that exits on failure of the user to agree to a EULA. The application must be fully usable after it is downloaded from the App Store. If you need to have a different EULA, that is something you can customize in the App Store metadata in iTunes Connect. – Brad Larson Jan 10 '11 at 19:42
  • possible duplicate of [Proper way to exit iPhone application?](http://stackoverflow.com/questions/355168/proper-way-to-exit-iphone-application) – Brad Larson Jan 10 '11 at 19:43
  • 4
    @John, also, the user must accept the EULA before downloading the app in the first place. Have you uploaded to the app store yet? They give you a space to put your own EULA in. – Stephen Furlani Jan 10 '11 at 19:49

4 Answers4

5

It says:

Don’t Quit Programmatically

Never quit an iOS app programmatically because people tend to interpret this as a crash. However, if external circumstances prevent your app from functioning as intended, you need to tell your users about the situation and explain what they can do about it. Depending on how severe the app malfunction is, you have two choices.

Display an attractive screen that describes the problem and suggests a correction. A screen provides feedback that reassures users that there’s nothing wrong with your app. It puts users in control, letting them decide whether they want to take corrective action and continue using your app or press the Home button and open a different app

If only some of your app's features are unavailable, display either a screen or an alert when people use the feature. Display the alert only when people try to access the feature that isn’t functioning.

j0k
  • 22,600
  • 28
  • 79
  • 90
Yucel Bayram
  • 1,653
  • 2
  • 22
  • 41
5

You can call exit(0) to terminate the app. But Apple don't like this as this gives the user a feeling of sudden crash. If you still want to have an exit function (with a potential risk of rejection) then you should also send your app delegate the applicationWillTerminate message (if you have anything important there) before performing the exit.

taskinoor
  • 45,586
  • 12
  • 116
  • 142
3

The only way for a user to exit an application is by pressing the Home button. You can't do it in your app, at least not in a way that Apple would accept.

Stephen Darlington
  • 51,577
  • 12
  • 107
  • 152
  • I have seen app that had an exit button. Can't remember the name. But yes, Apple don't like it and they may reject for it. – taskinoor Jan 10 '11 at 17:16
-1

You can try to use command:

exit(0);
Dmitry
  • 1,035
  • 2
  • 14
  • 27