EZForm
EZForm copied to clipboard
EZFormRadioField.unwireInputView throws exception : [UILabel setInputView:] unrecognized selector
Setup:
-(void)viewDidLoad {
/*...*/
//First (of 6 culprits)
EZFormRadioField *sampleRateField = [[EZFormRadioField alloc] initWithKey:InitFormDevice_SampleRate_Key];
[sampleRateField setChoicesFromArray:self.sampleRateOptions];
sampleRateField.validationRequiresSelection = YES;
sampleRateField.validationRestrictedToChoiceValues = YES;
[sampleRateField setFieldValue:@"30"];
[self.initializationForm addFormField:sampleRateField];
/*...*/
// Radio/Select Fields (Use labels)
for (NSString *t in radioFields) {
EZFormRadioField *f = [self.initializationForm formFieldForKey:t];
if([t isEqualToString:InitFormDevice_SampleRate_Key]) [f useLabel:self.lblDeviceSampleRate];
/*...*/
}
}
/*
Initialization of the form fields, and wiring them up has already completed. Now i'm trying to leave the form via the UINavigationController (back button).
*/
-(void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self.initializationForm unwireUserViews];
}
Error:
-[UILabel setInputView:]: unrecognized selector sent to instance 0x15d23ff0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UILabel setInputView:]: unrecognized selector sent to instance 0x15d23ff0'
Using XCode 5, iOS7 (iOS6 SDK), iPhone 4S (just incase someone needed this information)
With only a few exceptions like viewDidUnload (deprecated), I followed exactly how the example project built up and tore down the fields. This only seems to occur with the combination of EZFormRadioFields and UILabels.
The reason why I bring this up is because every time I fire up this view, memory consumption increases a bit, but when leaving the view, it doesn't get released (using ARC, etc, etc). Figured I would have to use the unwireUserViews to fix this. For the most part, up until it hits that exception, the memory usage drops a little bit.
Could I be missing something?
Same thing here. Tried calling -unwireUserViews in -viewWillDisappear:, but that can't work in my case because we have several instances of EZFormMultiRadioFormField in the form.
It looks like EZFormRadioField
combined with it's superclass EZFormTextField
are missing a few edge cases around unwiring the input view if it's a UILabel.
- (void)unwireInputView
{
if ([self.userView.inputView isKindOfClass:[UIPickerView class]]) {
UIPickerView *pickerView = (UIPickerView *)self.userView.inputView;
if (pickerView.dataSource == self) pickerView.dataSource = nil;
if (pickerView.delegate == self) pickerView.delegate = nil;
}
self.userView.inputView = nil;
}
It's clear here that if it's a label, it will fall over.
IMHO the userView/inputView behaviour needs some reworking here.