2

アプリで使用したいライブラリXLFORMSを見つけました。問題は、行とセクションが空の tableView だけで表示されないことです。私は自分のストーリーボードで、ビューを削除したビューコントローラーを作成したので、完全に空のビューコントローラーになりました。次に、サンプル コードを ViewDidLoad メソッドに追加しましたが、空の tableView だけですか? ライブラリのフィールドを表示するには、さらに何が必要ですか。

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];
4

3 に答える 3

4

私も同じことをしています。コードを ViewDidLoad に含めないでください。

したがって、.m ファイルに void を作成し、次のようにコードを入力します。

-(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];

}

これに加えて、inits が次のようになっていることを確認する必要があります。

- (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;
}

これが私と同じようにあなたにとってもうまくいくことを願っています. 幸運を!:)

于 2014-08-09T15:25:58.110 に答える
0

見落としている可能性があるもう 1 つのことは、テーブル ビュー (フォームがレンダリングされると予想される空のビュー コントローラーに追加されたビュー) を XLFormViewController の tableView アウトレットに接続することです。

@property IBOutlet UITableView * tableView;
于 2015-03-03T18:03:19.310 に答える