我可能需要一些帮助。
我在我的 Objective-C 项目中使用 XLForm。我有一个带选择器的第一行,您有四个不同的选项。然后是第二个选择器。但是只有在第一个选择器中选择了某个值时,第二个选择器才应该可用。
我知道 github-site 上有描述,但我真的不明白该怎么做。所以请帮我做这件事。
以下是我的代码的相关部分:
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"repeat" rowType:XLFormRowDescriptorTypeSelectorPickerViewInline title:@"Wiederholen:" ];
row.cellClass = [LehrerXLFormInlineSelectorCell class];
NSMutableArray *selectionArray = [NSMutableArray array];
for (NSNumber *item in [APIDataReplacement appointmentRepeatingList]) {
NSString *title = [APIDataReplacement appointmentRepeatingToString:item.intValue];
[selectionArray addObject:[XLFormOptionsObject formOptionsObjectWithValue:item displayText:title]];
}
row.selectorOptions = selectionArray;
if ([selectionArray count] == 0) {
[row setDisabled:@YES];
}
if (aItem) {
int repeatingID = [[aItem appointmentRepeatingId] intValue];
NSString *title = [APIDataReplacement appointmentRepeatingToString:repeatingID];
row.value = [XLFormOptionsObject formOptionsObjectWithValue:[NSNumber numberWithInt:repeatingID] displayText:title];
}else{
NSNumber *first = [[APIDataReplacement appointmentRepeatingList] firstObject];
NSString *title = [APIDataReplacement appointmentRepeatingToString:first.intValue];
row.value = [XLFormOptionsObject formOptionsObjectWithValue:first displayText:title];
}
[section addFormRow:row];
section = [XLFormSectionDescriptor formSectionWithTitle:@""];
[form addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"weekday" rowType:XLFormRowDescriptorTypeSelectorPickerViewInline title: @"Wochentag:"];
row.cellClass = [LehrerXLFormInlineSelectorCell class];
NSMutableArray *selectionArray1 = [NSMutableArray array];
for (NSNumber *item in [APIDataReplacement dayList]) {
NSString *title = [APIDataReplacement dayToString:item.intValue];
[selectionArray1 addObject:[XLFormOptionsObject formOptionsObjectWithValue:item displayText:title]];
}
row.selectorOptions = selectionArray1;
if (aItem) {
// AppointmentRepeating *currentRepeat = [aItem appointmentRepeating];
int dayID = [[aItem startday] intValue];
NSString *title = [APIDataReplacement dayToString:dayID];
row.value = [XLFormOptionsObject formOptionsObjectWithValue:[NSNumber numberWithInt:dayID] displayText:title];
}else{
NSNumber *first = [[APIDataReplacement dayList] firstObject];
NSString *title = [APIDataReplacement dayToString:first.intValue];
row.value = [XLFormOptionsObject formOptionsObjectWithValue:first displayText:title];
}
[section addFormRow:row];
section = [XLFormSectionDescriptor formSectionWithTitle:@""];
[form addFormSection:section];
这是两个选择器。我想我应该在 formRowDescriptorValueHasChanged 方法中做一些事情,但我不知道是什么。如果第一个选择器的值是“20”,那么第二个选择器应该被隐藏。
非常感谢您的帮助。