测试测试通过 | ✗ |
语言语言 | Obj-CObjective C |
许可证 | 自定义 |
发布最新发布 | 2014年12月 |
由 尚未申领 维护。
依赖 | |
BWLongTextViewController | ~> 1.0 |
ActionSheetPicker2 | ~> 0.1 |
BWSelectViewController | >= 0 |
FormKit.m 是一个帮助用表格视图构建表单的库。
当用户进行编辑时,它还会处理模型和视图(单元格)之间的数据同步。
在 iPhone 和 iPad 以及 iOS 6+ 的版本上,一切看起来都很不错。
将 FormKit 目录复制到您的项目中。
或者使用 Cocoapods
pod 'FormKit.m', :git => "https://github.com/brunow/FormKit.m.git", :tag => "0.4.0"
self.formModel = [FKFormModel formTableModelForTableView:self.tableView navigationController:self.navigationController];
self.formModel.labelTextColor = [UIColor blackColor];
self.formModel.valueTextColor = [UIColor lightGrayColor];
[FKFormMapping mappingForClass:[Movie class] block:^(FKFormMapping *mapping) {
[mapping sectionWithTitle:@"Information section" identifier:@"info"];
[mapping mapAttribute:@"title" title:@"Title" type:FKFormAttributeMappingTypeText];
[mapping mapAttribute:@"releaseDate" title:@"ReleaseDate" type:FKFormAttributeMappingTypeDate];
[mapping mapAttribute:@"suitAllAges" title:@"All ages" type:FKFormAttributeMappingTypeBoolean];
// Read-only field
[mapping mapAttribute:@"shortName" title:@"ShortName" type:FKFormAttributeMappingTypeLabel];
[mapping mapAttribute:@"numberOfActor" title:@"Number of actor" type:FKFormAttributeMappingTypeInteger];
[mapping mapAttribute:@"content" title:@"Content" type:FKFormAttributeMappingTypeBigText];
// Select fields using a picker or pushing a selection view controller
[mapping mapAttribute:@"choice"
title:@"Choices"
showInPicker:NO
selectValuesBlock:^NSArray *(id value, id object, NSInteger *selectedValueIndex){
*selectedValueIndex = 1;
return [NSArray arrayWithObjects:@"choice1", @"choice2", nil];
} valueFromSelectBlock:^id(id value, id object, NSInteger selectedValueIndex) {
return value;
} labelValueBlock:^id(id value, id object) {
return value;
}];
[mapping buttonSave:@"Save" handler:^{
}];
[self.formModel registerMapping:mapping];
}];
[self.formModel loadFieldsWithObject:movie];
[formMapping validationForAttribute:@"title" validBlock:^BOOL(NSString *value, id object) {
return value.length < 10;
} errorMessageBlock:^NSString *(id value, id object) {
return @"Text is too long.";
}];
Bruno Wernimont