hackiftekhar / IQDropDownTextField

TextField with DropDown support using UIPickerView
MIT License
309 stars 87 forks source link

selectedItem not nil #52

Closed codwam closed 7 years ago

codwam commented 8 years ago

case IQDropDownModeDatePicker: { return [self.dropDownDateFormatter stringFromDate:self.datePicker.date]; }

while I didn't select any items, it always return the current date

hackiftekhar commented 8 years ago

Yeah. It will alwas return a date. I probably have to set the date to textField.text too (If it's not appearing already).

codwam commented 8 years ago

So how to fix it? I have add a property,

var isEmpty: Bool { get { let text = self.valueForKey("text") as? String return text == nil || text!.isEmpty } }

And I want to ask another question: textFieldDidEndEditing doesn't effct?

hackiftekhar commented 8 years ago

Currently there is no way to achieve this. I may need to fix it(If date isn't appearing at the first moment).

hackiftekhar commented 7 years ago

Hey @codwam I forgot what was the actual issue. Could you please remind me again?

codwam commented 7 years ago

`-(void)doneClicked:(UIBarButtonItem*)button { [self.view endEditing:YES];

NSLog(@"textFieldTextPicker.selectedItem: %@", textFieldTextPicker.selectedItem);
NSLog(@"textFieldOptionalTextPicker.selectedItem: %@", textFieldOptionalTextPicker.selectedItem);
NSLog(@"textFieldDatePicker.selectedItem: %@", textFieldDatePicker.selectedItem);
NSLog(@"textFieldTimePicker.selectedItem: %@", textFieldTimePicker.selectedItem);
NSLog(@"textFieldDateTimePicker.selectedItem: %@", textFieldDateTimePicker.selectedItem);

}`

Changed you project "doneClicked" function like above. Then click "Date Picker Mode" TextField, just click "DONE" without select any thing. And check "Date","Time", "DateTime" selectedItem not nil with the console log.