How to prevent going to another Storyboard scene unless all data is present in current scene?

71 views Asked by At

I have an iPad app (XCode 4.6, iOS 6.2, ARC and Storyboards with a UITabController). The setup scene is the first scene displayed if required data is missing; I don't want the user to be able to leave that scene unless all required fields have valid data in them.

The only place I can think of is validating the presence of data while in -viewWillDisappear; however at that point it's too late to not change to the scene that the user tapped. It is possible for the user to tap another tab, thereby bypassing all of the existing validation.

Anybody have any ideas on how to prevent going to another scene if the required data is missing?

1

There are 1 answers

3
Steven Marlowe On

Can you disable the button that goes to the next scene until all of the data has be entered? Have a function that checks to make sure that checks the data in all of the fields each time the fields are either edited or on editing did end. Then if there is valid data in all fields set

    [nextSceneButton setEnabled:YES]; // To toggle enabled / disabled

Or another way you could do it is to tie the button to a function that uses and if statement to check to see if all of the data is present and if all data is present then allows the segue, but if it's not then pops an error message or highlights the textfield that doesn't have valid text yet.