1. David Keegan
  2. InAppSettings
  3. Issues
Issue #7 resolved

Bug in cell reuse with dequeueReusableCellWithIdentifier:

Anonymous created an issue

I have a settings bundle with several sections. When scrolling down cells in the second section are calling dequeueReusableCellWithIdentifier (as it should), but somehow too much let over state is coming along with it, such that items from the first section are showing up in the second. When scrolling back up (so that the first section is again visible), the opposite is happening (and a few entries are out of order). If I comment out cell = ((InAppSettingsTableCell *)[tableView dequeueReusableCellWithIdentifier:cellType]); and just replace it with cell = nil, then everything works as expected.

Comments (4)

  1. Peter Greis

    Contents of Root.plist

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
            <key>StringsTable</key>
            <string>Root</string>
            <key>PreferenceSpecifiers</key>
            <array>
                    <dict>
                            <key>Type</key>
                            <string>PSGroupSpecifier</string>
                            <key>Title</key>
                            <string>Live Tracker Data</string>
                    </dict>
                    <dict>
                            <key>Type</key>
                            <string>PSMultiValueSpecifier</string>
                            <key>Title</key>
                            <string>Tracker</string>
                            <key>Key</key>
                            <string>tracker</string>
                            <key>DefaultValue</key>
                            <string>0</string>
                            <key>Values</key>
                            <array>
                                    <string>0</string>
                                    <string>http://www.livetrack24.com/track.php?</string>
                                    <string>http://test.livetrack24.com/track.php?</string>
                            </array>
                            <key>Titles</key>
                            <array>
                                    <string>None</string>
                                    <string>Leonardo Live</string>
                                    <string>Leonardo Test</string>
                            </array>
                    </dict>
                    <dict>
                            <key>Type</key>
                            <string>PSTextFieldSpecifier</string>
                            <key>Title</key>
                            <string>Username</string>
                            <key>Key</key>
                            <string>username</string>
                            <key>DefaultValue</key>
                            <string></string>
                            <key>IsSecure</key>
                            <false/>
                            <key>KeyboardType</key>
                            <string>Alphabet</string>
                            <key>AutocapitalizationType</key>
                            <string>None</string>
                            <key>AutocorrectionType</key>
                            <string>No</string>
                    </dict>
                    <dict>
                            <key>Type</key>
                            <string>PSTextFieldSpecifier</string>
                            <key>Title</key>
                            <string>Password</string>
                            <key>Key</key>
                            <string>password</string>
                            <key>IsSecure</key>
                            <true/>
                            <key>KeyboardType</key>
                            <string>Alphabet</string>
                            <key>AutocapitalizationType</key>
                            <string>None</string>
                            <key>AutocorrectionType</key>
                            <string>No</string>
                    </dict>
                    <dict>
                            <key>Type</key>
                            <string>PSTextFieldSpecifier</string>
                            <key>Title</key>
                            <string>Glider Make</string>
                            <key>DefaultValue</key>
                            <string></string>
                            <key>Key</key>
                            <string>glidermake</string>
                            <key>IsSecure</key>
                            <false/>
                            <key>KeyboardType</key>
                            <string>Alphabet</string>
                            <key>AutocapitalizationType</key>
                            <string>None</string>
                            <key>AutocorrectionType</key>
                            <string>No</string>
                    </dict>
                    <dict>
                            <key>Type</key>
                            <string>PSTextFieldSpecifier</string>
                            <key>Title</key>
                            <string>  Model</string>
                            <key>DefaultValue</key>
                            <string></string>
                            <key>Key</key>
                            <string>glidermodel</string>
                            <key>IsSecure</key>
                            <false/>
                            <key>KeyboardType</key>
                            <string>Alphabet</string>
                            <key>AutocapitalizationType</key>
                            <string>None</string>
                            <key>AutocorrectionType</key>
                            <string>No</string>
                    </dict>
                    <dict>
                            <key>Type</key>
                            <string>PSMultiValueSpecifier</string>
                            <key>Title</key>
                            <string>Traveling via...</string>
                            <key>Key</key>
                            <string>transport</string>
                            <key>DefaultValue</key>
                            <string>Paraglider</string>
                            <key>Values</key>
                            <array>
                                    <string>1</string>
                                    <string>2</string>
                                    <string>4</string>
                                    <string>8</string>
                                    <string>16</string>
                                    <string>32</string>
                                    <string>64</string>
                                    <string>128</string>
                                    <string>16385</string>
                                    <string>16386</string>
                                    <string>16388</string>
                            </array>
                            <key>Titles</key>
                            <array>
                                    <string>Paraglider</string>
                                    <string>Flex wing FAI1</string>
                                    <string>Rigid wing FAI5</string>
                                    <string>Glider</string>
                                    <string>Paramotor</string>
                                    <string>Trike</string>
                                    <string>Powered Flight</string>
                                    <string>Hot Air Balloon</string>
                                    <string>Walk</string>
                                    <string>Run</string>
                                    <string>Bike</string>
                            </array>
                    </dict>
                    <dict>
                            <key>Type</key>
                            <string>PSMultiValueSpecifier</string>
                            <key>Title</key>
                            <string>Final Message</string>
                            <key>Key</key>
                            <string>message</string>
                            <key>DefaultValue</key>
                            <string>0</string>
                            <key>Values</key>
                            <array>
                                    <string>0</string>
                                    <string>1</string>
                                    <string>2</string>
                                    <string>3</string>
                                    <string>4</string>
                            </array>
                            <key>Titles</key>
                            <array>
                                    <string>Everything OK</string>
                                    <string>Need retrieve</string>
                                    <string>Need some help, nothing broken</string>
                                    <string>Need help, maybe something broken</string>
                                    <string>HELP! Serious injury</string>
                            </array>
                    </dict>
                    <dict>
                            <key>Type</key>
                            <string>PSTextFieldSpecifier</string>
                            <key>Title</key>
                            <string>Log interval (seconds)</string>
                            <key>Key</key>
                            <string>loginterval</string>
                            <key>DefaultValue</key>
                            <string>60</string>
                            <key>IsSecure</key>
                            <false/>
                            <key>KeyboardType</key>
                            <string>NumbersAndPunctuation</string>
                            <key>AutocapitalizationType</key>
                            <string>None</string>
                            <key>AutocorrectionType</key>
                            <string>No</string>
                    </dict>
                    <dict>
                            <key>Type</key>
                            <string>PSTextFieldSpecifier</string>
                            <key>Title</key>
                            <string>Accuracy threshold (meters)</string>
                            <key>DefaultValue</key>
                            <string>100</string>
                            <key>Key</key>
                            <string>threshold</string>
                            <key>IsSecure</key>
                            <false/>
                            <key>KeyboardType</key>
                            <string>NumbersAndPunctuation</string>
                            <key>AutocapitalizationType</key>
                            <string>None</string>
                            <key>AutocorrectionType</key>
                            <string>No</string>
                    </dict>
                    <dict>
                            <key>Type</key>
                            <string>PSGroupSpecifier</string>
                            <key>Title</key>
                            <string>IGC Export Info (Pilots only!)</string>
                    </dict>
                    <dict>
                            <key>Type</key>
                            <string>PSTextFieldSpecifier</string>
                            <key>Title</key>
                            <string>Pilot Name</string>
                            <key>Key</key>
                            <string>pilotname</string>
                            <key>DefaultValue</key>
                            <string></string>
                            <key>IsSecure</key>
                            <false/>
                            <key>KeyboardType</key>
                            <string>Alphabet</string>
                            <key>AutocapitalizationType</key>
                            <string>None</string>
                            <key>AutocorrectionType</key>
                            <string>No</string>
                    </dict>
                    <dict>
                            <key>Type</key>
                            <string>PSTextFieldSpecifier</string>
                            <key>Title</key>
                            <string>Glider ID</string>
                            <key>Key</key>
                            <string>gliderid</string>
                            <key>DefaultValue</key>
                            <string></string>
                            <key>IsSecure</key>
                            <false/>
                            <key>KeyboardType</key>
                            <string>Alphabet</string>
                            <key>AutocapitalizationType</key>
                            <string>None</string>
                            <key>AutocorrectionType</key>
                            <string>No</string>
                    </dict>
                    <dict>
                            <key>Type</key>
                            <string>PSTextFieldSpecifier</string>
                            <key>Title</key>
                            <string>UTC Offset (H:MM)</string>
                            <key>Key</key>
                            <string>utcoffset</string>
                            <key>DefaultValue</key>
                            <string>0:00</string>
                            <key>IsSecure</key>
                            <false/>
                            <key>KeyboardType</key>
                            <string>NumberAndPunctuation</string>
                            <key>AutocapitalizationType</key>
                            <string>None</string>
                            <key>AutocorrectionType</key>
                            <string>No</string>
                    </dict>
                    <dict>
                            <key>Type</key>
                            <string>PSGroupSpecifier</string>
                            <key>Title</key>
                            <string>About</string>
                    </dict>
                    <dict>
                            <key>Type</key>
                            <string>PSTitleValueSpecifier</string>
                            <key>Title</key>
                            <string>Version</string>
                            <key>Key</key>
                            <string>version</string>
                            <key>DefaultValue</key>
                            <string>1.2.0</string>
                            <key>IsSecure</key>
                            <false/>
                    </dict>
                    <dict>
                            <key>Type</key>
                            <string>PSTitleValueSpecifier</string>
                            <key>Title</key>
                            <string>Programming</string>
                            <key>Key</key>
                            <string>programming</string>
                            <key>DefaultValue</key>
                            <string>freethinker gmbh</string>
                            <key>IsSecure</key>
                            <false/>
                    </dict>
            </array>
    </dict>
    </plist>
    
  2. David Keegan repo owner

    Great find!

    The problem was the cells were only correctly being setup when initialized, which only happened the first time the cell was displayed. Thats why setting cell=nil worked, because the cell was then created every time a new one was displayed.

    I moved around the code for updating the cell UI elements, this should fix the problem you reported.

    Resolved in: a464a9d29e67

  3. Log in to comment