iOS, leftButtonItem 'are you sure?' approach to confirming exit from screen approach?

Refresh

April 2019

Views

30 time

1

I'm trying to figure out the standard approach or the best approach.

I don't want my users (children) to accidentally tap the back button and lose what they have entered into a view.

1) In a very old implementation, there's a leftBarButtonItem with an action which shows an alert asking are you sure. But I can't do this without losing the arrow provided by the back button and I don't want to add my own < image.

I've looked into the back button solution of a variable where you keep track of other routes out of the view, then do something in viewDidDisappear, but I won't be able to show an alert and cancel here.

2) I could have my own buttons and not have a navigation bar at all, but the buttons aren't going to look normal.

What;s the standard approach to solve this?

1 answers

0

It is not recommended to change the action of the back button. This does include presenting alerts and other UI elements that delay or cancel the back action.

What you can do, is present the controller modally and instead of a back button use a different glyph, such as a cross. Then present an alert when the user taps the button (eg snapchat on creating a snapsterpieces)

Sam