mardi 14 juin 2016

What is the best practice to add validation code on a Back button action in a UIViewController?


I have a UIViewController that is created via instantiateViewControllerWithIdentifier. In that controller, the user may enter some text that I need to validate before saving. There is a back button that the user clicks and that will trigger the save. But if there is an error, I will not allow the user to go back. What is the best practice for this? I read stackoverflow and the solution seems to be overriding UINavigationController, which I think is some sort of hack. I cannot put the code in willMovetoParentViewController since there is no return of true or false. It will still proceed.


Aucun commentaire:

Enregistrer un commentaire