I have a UINavigationController with a root view controller, and then I push the UIViewController on the navigation controller stack. When the user drops the backBarButtonItem, I would like to be able to see a warning popup if there are certain conditions and cancels the view controller pop. For example, a user may make certain selections, but some combination of them may be invalid, so I want to notify them of changes.
I know that I can prevent the user from making an invalid combination or display a warning when the wrong combination is selected, but I would not. The user can change the selection and may know that a certain combination is invalid, but I would prefer that they choose what makes the combination invalid, and then change something else (and notify them if they have not made changes before trying to go to the previous screen). For example, if I forbid them to choose something that makes an invalid combination, then they may have to scroll the screen, change something, then scroll back instead of making choices, and then scroll and change something.
Using viewWillDisappear: does not work, because although I can create a warning view, I cannot determine how to prevent pop from appearing. A warning window is displayed, but the view controller still appears, and they return to the root view controller (with the warning view displayed).
Is there any way to prevent pop from appearing? If not, does it need something to stand in order to report an error or is it superfluous and / or esoteric?
source share