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];
I am doing the same thing. The code should not be in ViewDidLoad.
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! :)
Another thing you might have missed is hooking up your table view (the one added to the empty view controller in which you expect the form to render) to the tableView outlet in XLFormViewController:
@property IBOutlet UITableView * tableView;
Subclass your ViewController with XLFormViewController and not UIViewController. After creating form add 1 line of code self.form = form
.