0

私は2つのテーブルビューを持っており、セルはそれがどのテーブルビューであるかに応じて構成されています。それらはcellForRowAtIndexPathを介し​​てメソッドに実装されていindexpath.sectionます。ただし、2 つのテーブルビューのセクション数は異なります。この問題を解決する方法はありますか? ありがとう

セクション番号が異なると言ったのは、次のことを意味していました。

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    if(tableView==byTeam) {
        return [teamnameswithoutRepeat count];
    } else {
        return [JSONPointsArray count];
    }
    // Return the number of sections.
}

以下を使用するとcellforrowatindexpath:

label.text=[currentarray objectAtIndex: indexpath.section];

indexpath.sectionが大きすぎるため、範囲エラーが発生します。JSONPointsArrayセクションの数を決定するために使用していますが、アプリを実行すると、チームごとのテーブルビューに正しい量のセクションがあります。

4

1 に答える 1

0

あなたのcellForRow...方法は似ている必要があります:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (tableView == byTeam) {
        // process the "byTeam" table using the teamnamesiwthoutRepeat array
    } else {
        // process the other table using the JSONPointsArray array
    }
}
于 2013-05-31T16:25:18.553 に答える