0
- (UITableViewCell *)tableView:... cellForRowAtIndexPath:... {
    // init and sanity check

    if (indexPath.row == 0) {
        // make cell look like a section header
        // easier and less complex than using a custom header view

        NSLog(@"header");
        // should prove that only four cells get the bg image
        // and yet, almost every time the table is reloaded
        // one more cell unexpectedly gets the background
        // without putting another line in the debugger
    } else {
        // normal cells after row 0
        // BUG: some of these are getting the row 0 background

        NSLog(@"row");
        // firing exactly the right number of times --
        // once for each row with an index greater than 0
        // so why are some of these cells getting the header bg?

        // when these cells get the headers' contents
        // they behave exactly as one would expect
        // except that they should be the normal rows
    }

    // misc stuff, not causing problems

    return cell;
}

別のデータをテーブルにダンプするためだけにアプリを完全に再起動するようにユーザーに強制する以外に、バグを修正する方法がわかりません。

すべてのセクションを折りたたむ (つまり、expandedSectionsセットを空にしてリロードし、疑似ヘッダーのみを表示する) と、問題はそれほど深刻ではなくなりますが、問題は解決しません。


編集:

初期読み込み:スクリーンショット
リロード後:スクリーンショット
iPadアプリなので画像ではなくリンクです。
テスト用にダミー コンテンツを使用します。

これは何か助けになりますか?深刻な問題を解決するにはさらに多くのコードが必要であることはわかっていますが、ビュー全体のコードへのリンクを除いて、他に何を追加すればよいかわかりません。

4

2 に答える 2

0

おそらくセルキャッシュに関連しています...行== 0の画像を設定し、それ以外の場合はクリアしないことについての何か...しかし、表示しているコードの量が限られているため、より具体的にするのは困難です。

于 2012-08-20T15:19:52.857 に答える
0

最初のセルに別のセル識別子を設定し、残りのセルに別のセル識別子を設定しようとしましたか? tableView は、新しいセルを作成するときに同じセル タイプを再利用するため、それらが混同される可能性があります。タイプごとに異なるセル識別子を使用することで、各セルをいつ使用するかを正確に知ることができます。

于 2012-08-21T08:44:35.463 に答える