0

UIViewController のプロパティとして UITableView があり、特定の行のセルに[tableView cellForRowAtIndexPath:indexPath].

1 つのメソッド呼び出しで、次の複数の呼び出しが表示されると予想する必要があります。

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

私の UITableViewCell のそれぞれには、アクセスしようとしているテキスト データの UITextField があります。

これが私がやっていることです:

for (int section = 0; ix < countOfSections; ++section)
{
    NSInteger countOfRowsInSection = // attained
    for (int row = 0; row < countOfRowsInSection; ++row)
    {
        NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section];

        // the follow call seems to elicit multiple invocations 
        // on my table delegate's
        // - (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

        UITableViewCell *cell = [self.tableview cellForRowAtIndexPath:indexPath];

        // Access some custom data
    }
}

すべてのセクションと行の UITableViewCell のそれぞれの UITextField に格納されているすべてのデータにアクセスするより良い方法はありますか?

4

1 に答える 1

1

ビューをデータ ストレージに使用しようとするべきではありません。tableView:cellForRowAtIndexPath:テーブルのデータ ソースとして使用しているものには、が呼び出されたときにセルのコンテンツを提供するデータを含むオブジェクトの配列 (またはその他の構造) が必要です。

その情報への他のアクセスが必要な場合は、表示ではなくデータ構造から直接取得する必要があります。

于 2012-08-08T18:00:26.343 に答える