I am using the approach described in this stackoverflow posting to retrieve values from a textfield. My problem is that the tableview is presented modally and I have a save button that validates the input and stores it.
The problem is that the textFieldDidEndEditing method is not called when the user clicks an UIBarButtonItem (= the save button, which closes the modal view).
In this event (when the user wants to save the input) I would like to validate it. But the values are stored in properties in the textFieldDidEndEditing. Due to the fact that this method is not called, I cannot validate the input values correctly.
Does anyone have a hint or solution on this?
Thanks in advance!
Okay, here we go:
Thanks to @Lefteris and his idea with storing the current index. Due to the fact that I cannot store the index into the
tagattribute I decided to store the activeindexPathand additionally the activetextField. (I know, a reference to theUITextFieldwould have been enough but I needed it for other stuff)First I have added these two properties:
Then I implemented
textFieldDidBeginEditing:andtextFieldDidEndEditing:ofUITextFieldDelegate.In
textFieldDidEndEditing:I am storing the values into my properties (such asself.firstName,self.lastName, and so on…) by using the method[self assumeInput:input withIndexPath:self.activeIndexPath];.In my
saveAction-Method I am storing the value from the currently activeTextField.… and that’s it!
Hope it helps! Thanks to @Lefteris for his input.
Best,
Chris