2012-11-23 28 views
0

我目前使用Sensible TableView框架爲新應用程序創建搜索過濾器蒙版。 所有的工作都很好,但最新的Screendesign提供了新的問題。CustomController類作爲SensibleTableView中的CustomCell?

現在需要選擇最小值和最大值之間的範圍。現在我們不必使用兩個數字文本框來定義範圍,而是需要創建一種新的自定義RangeSlider類型(對於UISliderView來說很熟悉)。現在,我創建了RangeSlider(具有兩個縮略圖的Slider)作爲CustomClass,沒有xib文件。我現在必須在我的tableview中實現這個customCell? 仍然無法弄清楚如何通過STV做到這一點。

我RangeSlider需要一些屬性進行設置:

  • 浮動minimumValue;
  • float maximumValue;
  • float minimumRange;
  • float selectedMinimumValue;
  • float selectedMaximumValue;

並通過更改屬性值來響應用戶交互。

Range Slider: That's how it looks like.

我的問題在短期: 如何實現我的RangeSlider類作爲CustomCell,沒有XIB文件? And ..是否有可能使用SCUserDefaultsDefinition跟蹤我的customCell的userInteraction呢?

這就是我創造我STV方式:

SCUserDefaultsDefinition *userDefaultsDef = [SCUserDefaultsDefinition definitionWithDictionaryKeyNamesString:@"Search Filter:(gender,ageRangeSlider,zip,country)"]; 
SCPropertyDefinition *genderDef = [userDefaultsDef propertyDefinitionWithName:@"gender"]; 
genderDef.title = @"Gender"; 
genderDef.required = TRUE; 
genderDef.type = SCPropertyTypeSelection; 
genderDef.attributes = [SCSelectionAttributes attributesWithItems:[NSArray arrayWithObjects:@"f", @"m", nil] allowMultipleSelection:NO allowNoSelection:NO]; 
genderDef.autoValidate = TRUE; 

/*#### CUSTOMCELL IMPLEMENTATION HERE #### */ 

SCPropertyDefinition *zip = [userDefaultsDef propertyDefinitionWithName:@"zip"]; 
zip.title = @"Zip-Code"; 
zip.type = SCPropertyTypeNumericTextField; 
zip.attributes = [SCNumericTextFieldAttributes attributesWithMinimumValue:[NSNumber numberWithInt:01] maximumValue:[NSNumber numberWithInt:99] allowFloatValue:NO]; 
[self.tableViewModel generateSectionsForUserDefaultsDefinition:userDefaultsDef]; 
SCTableViewSection *formSection = [self.tableViewModel sectionAtIndex:0]; 
formSection.cellActions.valueChanged = ^(SCTableViewCell *cell, NSIndexPath *indexPath) 
{ 
    NSLog(@"\n\n*********** Key Binding Log ***********\n"); 
    NSLog(@"Value: %@\n", [cell boundValue]); 
}; 

將是巨大的,如果有人能幫助! 我真的很感激!請告訴我,如果你需要更多的信息。

感謝,

拉爾斯 (SRY我的英文不好)

回答

0

好了,問題解決了!

這裏談到的解決方案: 要STV添加customClass作爲CustomCell,你必須定義使用類名/ Nibname和你customControl作爲objectBinding的標籤SCCustomPropertyDefinition。

SCUserDefaultsDefinition *userDefaultsDef = [SCUserDefaultsDefinition definitionWithDictionaryKeyNamesString:@"Search Filter:(gender,ageRangeSlider,zip,country)"]; 

SCCustomPropertyDefinition * customControl = [SCCustomPropertyDefinition definitionWithName:@"ageRangeSlider" uiElementClass:[CustomControlClass class] objectBindingsString:@"1:selectedRange;"]; 
[userDefaultsDef insertPropertyDefinition:customControl atIndex:1]; 

創建和添加新的PropertyDefinition您UserDefaultsDefinition後,您可以使用來自PropertyDefinition的ObjectBindingString(@「1:的selectedRange;」)來配置響應特性在CustomControlClass。 該數字爲自定義單元格中的每個控件顯示IB標籤,而字符串表示該屬性用作此控件的ResponseValue。

希望這可以幫助未來的其他開發者。