0

こんにちは、私のアプリでは、動的に値に基づいてテーブルビューを作成したいので、(cell1 with label,label2)、(cell2 with label1,textfield2)、(cell3 with label1,segment1) などのさまざまなコントロールを持つ UItableView セルを追加する必要があります。私のXibのUItableViewCell.しかし、それらを動的にロードすることはできません。

4

1 に答える 1

1

cellForRowAtIndexPathメソッドで実行する必要があります。このようなもの。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    if (indexPath.row == 0) {
       return cell0;
    } else if (indexPat.row == 1) {
        return cell1;
    } else if (indexPat.row == 2) {
        return cell2;
    } else if (indexPat.row == 3) {
        return cell3;
    }

}

cell0、cell1、cell2、cell3は、Interface Builderで作成し、IBOutletにリンクしたセルです。

于 2012-10-17T06:44:12.447 に答える