0

In my iOS app's Settings screen, there is one setting which is quite fundamental. I wish to inform users about this with a UIAlertView.

Preferably I would display this when the back button is pressed (and thus they are finished editing their settings). However, is this possible, or even allowed by Apple? If so, how?

My second choice would be to show the UIAlertView as soon as the setting is changed, but if this is possible its not really a preference. And if it is possible, how do I do it?

Edit - 2nd August 2012 : My app has its own Settings screen in addition to the built in Settings screen, so my question applies to both screens. Also, note that the setting is a UISwitch.

Also, I preferably would like a cancel button on the UIAlertView that allows the user to NOT leave the settings screen once they have read the warning. Is this possible?

Andy A
  • 4,191
  • 7
  • 38
  • 56
  • 1
    You have no control over the Settings app apart from displaying your settings. I'd recommend moving your settings in-app. The built-in Settings app is far too limited for third-parties. – Tom Irving Aug 01 '12 at 15:20
  • Hi Tom. My app has its own Settings screen in addition to the built in Settings. So my question applies to both. – Andy A Aug 01 '12 at 15:21
  • Just a note, I would find it quite annoying if a UIAlertView showed up every time I left the Settings view controller. – runmad Aug 01 '12 at 15:24
  • Hi runmad. This alert would only occur when this particular setting was changed (which the user isn't likely to do more than once). – Andy A Aug 01 '12 at 15:28
  • By what mechanism does the user change the setting? Knowing what kind of control you're using (say, a `UISwitch`) would be very helpful. – oltman Aug 01 '12 at 15:40
  • It's a UISwitch. I'll update my question to make this clear. – Andy A Aug 02 '12 at 08:15

2 Answers2

2

You cannot do it for the iOS Settings app, but in your own app's settings view controller you could show an alert on viewWillDisappear:

UPDATE: From the comments, you want to override the back button behaviour. I would suggest that you hide the back bar button item and create your own button. Then if the user accepts in the prompt, you call [self popViewControllerAnimated:YES];

runmad
  • 14,846
  • 9
  • 99
  • 140
  • Mmm nice idea. At a guess, if the user chooses that they DON'T want to make the change, should I simply not call 'super viewWillDisappear'? Or is this bad? – Andy A Aug 02 '12 at 08:30
  • Not calling viewWillDisappear doesn't stop the screen from going back. Is it possible to do this? – Andy A Aug 02 '12 at 08:41
  • I am not sure I understand your question then? I thought you wanted to show an alert view when the user leaves the view controller. – runmad Aug 02 '12 at 13:22
  • Hi. When they press 'back', I'd like an alert to pop up giving them the option to either go back or not. However, I don't yet see a way of using 'viewWillDisappear' for this, because if the user chooses NOT to go back once they have read the warning, I don't see a way of cancelling the 'back' within viewWillDisappear. – Andy A Aug 02 '12 at 13:38
0

As of yet I do not believe my aim is possible on the traditional settings screen.

On my own settings screen, a UIAlertView is possible when the back button is pressed. The solution can be found here. However, it breaks the parts of my app which automatically pop screens without the user pressing the back button.

I therefore simply have made a UIAlertView pop up when the setting itself is changed. I haven't included a 'cancel' button on the pop up.

Further alternative answers here on Stack Overflow, however, will be welcome!

Community
  • 1
  • 1
Andy A
  • 4,191
  • 7
  • 38
  • 56