Question

I want to show an alert when a user taps the Home button. I tried with:

  • applicationWillResignActive
  • applicationDidEnterBackground
  • applicationWillEnterForeground
  • applicationWillTerminate

... but nothing worked. For the first three, the alert comes when the application comes back to foreground from background. I want to show the alert immediately after Home button is pressed. Is there any way to do this?

Also: I want to run the app in foreground itself, or send to background as per user input.

Was it helpful?

Solution 2

As far as I know, You can't do that. The home button functionality is not accessible via any event handlers in Objective C.

You only get "notified" by the UIApplicationDelegate whenever the app is resigned from being active or becomes active, but you can't display any alerts there since you can't lock the home button or make the user wait for an alert for the home button to work.

In summation, The home button must always go home, It doesn't matter what your application wants or needs :)

OTHER TIPS

Sorry It cant be achieved .

The methods you mentioned happens after the button press event but it cannot stop the event of home button

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top