开发者

UITableView section header in editing mode only

开发者 https://www.devze.com 2022-12-22 08:26 出处:网络
The table view section headers in my plain (non-grouped) UITableView only appear when the table has been placed into editing mode. This is because I have two sections in the table view: Active and Ina

The table view section headers in my plain (non-grouped) UITableView only appear when the table has been placed into editing mode. This is because I have two sections in the table view: Active and Inactive. I only wish the Active section to be displayed normally, but require both Active and Inactive to be displayed when in editing mode. Thus, having the section hea开发者_如何转开发ders display when in editing mode allows the easy distinction between the two table view sections.

However, I am encountering the following problem. When the edit button is tapped (to place the UITableView into editing mode) the section headers are inserted and a strip of white space appears above each section in the UITableView. However, the header itself does not display - just white space which exactly matches the dimensions of the section header bar. If I scroll the UITableView (even ever so slightly, not even taking the section header space off-screen) the section header bar immediately appears. It almost seems like the UITableView is not repainting this space correctly.

The way that I have got the section headers to display in editing mode only is by placing an if (self.tableView.editing) { } statement in the titleForHeaderInSection delegate method.

I have tried doing a [self.tableView reload] and alike which does display the section headers correctly, but also eliminates the nice animation between editing and non-editing mode (which I obviously wish to keep).

Any ideas on how to resolve this strange problem would be much appreciated!


The best I've been able to come up with is this:

[tableView reloadSections:[NSIndexSet indexSetWithIndex:0] 
         withRowAnimation:UITableViewRowAnimationFade];

The animation works, but it's not quite as nice as the default editing animation.

This assumes you want to reload the header/footer in section 0.

0

精彩评论

暂无评论...
验证码 换一张
取 消