XLForms 集成空 tableView [英] XLForms integration empty tableView
问题描述
我找到了我希望在我的应用中使用的库 XLFORMS.问题是它没有显示任何行和部分,只是一个空的 tableView.我在我的故事板中创建了一个视图控制器,我在其中删除了视图,因此它只是完全空的视图控制器.然后我将示例代码添加到 ViewDidLoad 方法中,但只是一个空的 tableView?我还需要什么才能显示库中的字段.
I've found the library XLFORMS which i wish to use in my app. The problem is that it is not showing any rows and section just an empty tableView. i've in my storyboard created a viewcontroller where i've deleted the view so its just and completely empty viewController. Then i've added the example code to the ViewDidLoad method, but just a empty tableView? What do i need more in order to show the fields from the library.
XLFormDescriptor * form;
XLFormSectionDescriptor * section;
XLFormRowDescriptor * row;
form = [XLFormDescriptor formDescriptorWithTitle:@"Add Event"];
// First section
section = [XLFormSectionDescriptor formSection];
[form addFormSection:section];
// Title
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"title" rowType:XLFormRowDescriptorTypeText];
[row.cellConfigAtConfigure setObject:@"Title" forKey:@"textField.placeholder"];
[section addFormRow:row];
// Location
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"location" rowType:XLFormRowDescriptorTypeText];
[row.cellConfigAtConfigure setObject:@"Location" forKey:@"textField.placeholder"];
[section addFormRow:row];
// Second Section
section = [XLFormSectionDescriptor formSection];
[form addFormSection:section];
// All-day
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"all-day" rowType:XLFormRowDescriptorTypeBooleanSwitch title:@"All-day"];
[section addFormRow:row];
// Starts
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"starts" rowType:XLFormRowDescriptorTypeDateTimeInline title:@"Starts"];
row.value = [NSDate dateWithTimeIntervalSinceNow:60*60*24];
[section addFormRow:row];
推荐答案
我也在做同样的事情.代码不应在 ViewDidLoad 中.
I am doing the same thing. The code should not be in ViewDidLoad.
因此,在您的 .m 文件中创建一个空白,然后输入代码,使其看起来像这样:
So, create a void in your .m file, and enter the code so it looks like this:
-(void)initform
{
XLFormSectionDescriptor * section;
XLFormRowDescriptor * row;
self.form = [XLFormDescriptor formDescriptorWithTitle:@"Add Event"];
// First section
section = [XLFormSectionDescriptor formSection];
[self.form addFormSection:section];
// Title
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"title" rowType:XLFormRowDescriptorTypeText];
[row.cellConfigAtConfigure setObject:@"Title" forKey:@"textField.placeholder"];
[section addFormRow:row];
// Location
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"location" rowType:XLFormRowDescriptorTypeText];
[row.cellConfigAtConfigure setObject:@"Location" forKey:@"textField.placeholder"];
[section addFormRow:row];
// Second Section
section = [XLFormSectionDescriptor formSection];
[self.form addFormSection:section];
// All-day
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"all-day" rowType:XLFormRowDescriptorTypeBooleanSwitch title:@"All-day"];
[section addFormRow:row];
// Starts
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"starts" rowType:XLFormRowDescriptorTypeDateTimeInline title:@"Starts"];
row.value = [NSDate dateWithTimeIntervalSinceNow:60*60*24];
[section addFormRow:row];
}
除此之外,您还需要确保您的初始化看起来像这样:
In addition to do this, you need to make sure your inits look like this:
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
[self initform];
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder;
{
self = [super initWithCoder:aDecoder];
if (self) {
// Custom initialization
[self initform];
}
return self;
}
希望这对你和我一样有效.祝你好运!:)
Hope this works as well for you as it did for me. Good luck! :)
这篇关于XLForms 集成空 tableView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!