Closed OxyFlax closed 8 years ago
There Is a delegate method for this something like didSelectItem. This will do the trick for you.
What do you mean?
When you select a value, I need to call the function checkFields that is this one:
-(void)checkFields { self.createButton.enabled = self.pseudoTextField.text.length > 0 && self.passwordTextField.text.length > 0 && self.confirmPasswordTextField.text.length > 0 && _questionTextFieldPicker.selectedRow != -1 && _questionAnswerTextField.text.length > 0 && _cityTextField.text.length > 0 && _addressTextView.text.length > 0; }
Sorry, I'm new in Objective-C so I don't know where to put didSelectItem
Ok, then you could learn about delegate first. There are delegate methods to get a callback like you want.
Ok thanks, I tried that: `-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
// my action
}` But it doesn't work. Is that what you were talking about?
That's the delegate of UIPickerView. You should use IQDropDownTextField delegates.
Ok sorry, I didn't look at the .h file. I tried that:
-(void)textField:(nonnull IQDropDownTextField*)textField didSelectItem:(nullable NSString*)item { [self checkFields]; NSLog(@"Problem is from elsewhere"); }
But it doesn't work either.
You didn't set textField.delegate property to self that's why you didn't get a callback.
Thank you very much, it worked. And you helped me for my future development I think, as I now know better how to use delegate :)
I would like to call a method when the value is change (in order to enable a button when something is selected in pickerView) but nothing seems to work, do you have any idea? I tried this:
[_TextFieldPicker addTarget:self action:@selector(checkFields) forControlEvents:UIControlEventValueChanged];