views:

287

answers:

5

In the editing mode of one of my tableviews, I delete a row from a section. The section below has a header. The deletion of the row in the section above leads to duplication of the section header below. So I have 2 header titles, one above the other.

I also tried forcing a reload of the section after the delete to no avail:

[self.tableView beginUpdates];    
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];            
NSIndexSet * indexSet = [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(3,1)];
[self.tableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationFade];
[indexSet release];
[self.tableView endUpdates];

Any ideas of what I have done wrong?

It is also interesting that the header that failed to get removed is not "seen". If I scroll right off the content of the table view, and let it snap back, only the top header view is seen. It always ignores the header that should have been removed.

A: 

Although I haven't used multiple sections, I have had a similar issue with a single section. If you don't change the underlying data source (the count of the number of items being key) the table view doesn't render properly. I would make sure that your underlying data source has the row removed before you update the display.

Epsilon Prime
A: 

I have a reverse problem!

When I collapse the section rows, hide them by setting number of rows to 0, the header also hides. but scrolling the table little, makes the header visible. it seems the table view is not refreshed. I tried to call the setNeedsDisplay on the tableview and parent view, but still did not solve the problem. any great idea ?

karim
A: 
karim
A: 

@karim Did you ever figure it out? I'm having the same issue

Robert
A: 

Table section collapse/expand seems do not work properly. It would be great it worked. I took an alternative approach to implement my target. I use a scrollview to contain all other view and tables. By this way I am having some problem to capture cell selection since I used separate view controller for each section (now View).

karim