UITableView - Section header's disclosure button changes randomly

I'm trying to make my own table view displaying hierarchical data based on Apple's "Table View Animations and Gestures" sample code. Everything works fine in Apple's demo, until I add more root items than it is displayable on the screen.

Problem is that if I expand first root item and scroll down, the disclosure button of last root item displays expanded state. Then if I scroll to the top (sometimes it needs to be repeated few times), the disclosure button of first item already shows collapsed state but the item is still expanded. If I click to such item the app crashes with error:

'NSInternalInconsistencyException', reason: 'attempt to insert row 0 into section 0, but there are only 0 rows in section 0 after the update'

I have copied the sample code from here: https://developer.apple.com/library/ios/samplecode/tableviewupdates/TableViewUpdates.zip

Data source is "PlaysAndQuotations.plist" and it has been changed following: Copy all 3 root dict items (also with their array of dicts) 4 times, so it contains 12 root items with all their subitems.

My adapted Plist data file can be downloaded here: https://drive.google.com/file/d/0B__nLmZ1h_-eUHVlTV9FbzN2aGc/edit?usp=sharing

Please help me to find out, why is the disclosure button changing its state by itself and how to fix the crashes.


This has solved the issue

  • (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { Add the following :

    if (section == self.openSectionIndex ){
        sectionHeaderView.disclosureButton.selected = YES;
        sectionHeaderView.disclosureButton.selected = NO;

APLSectionHeaderView - (void)toggleOpenWithUserAction:(BOOL)userAction {

// Comment this line self.disclosureButton.selected = !self.disclosureButton.selected; 
if (userAction) {
    // toggle the disclosure button state
    self.disclosureButton.selected = !self.disclosureButton.selected; //Add here 

Need Your Help

Change URIEncoding in OpenShift JBoss AS 7

java openid jboss7.x openshift

I am building an testing app with Spring Security using the OpenId module. I also use the jQuery OpenId plugin to support some providers.