I have a UITableView with a negative top content inset (-20). I use the negative inset for a shadow effect: The table header is a shadow gradient. The negative inset causes the shadow to only appear when the user is dragging the table down (similar to the Alarms table in the Clock app).
This works fine. Until I start reordering the rows (by standard UITableView reordering mechanism).
The instant I grab the first row, the whole table jumps down, so that the bottom edge of the last row is aligned to the bottom of the screen. This is a really weird glitch. When I release the row (at the same or some other position), the table stays in this strange, misaligned state. When I do some scrolling, the table returns to its original position.
This also happens for the other rows if I drag them to the top row. Reordering below the top row works fine. When I change the content inset to zero (or a positive number), the glitch does not occur.
It really seems like a bug in iOS (5.0) - unless I am missing something? Any idea how to work around this?
I'm also experiencing this exact issue in iOS 6.
I couldn't find a fix, but there's a workaround which might work if your table only has a single section. Basically, instead of setting the content inset to a negative value, you can set a negative section header height. This seems to have the same effect as the negative inset -- nudging the entire contents of the scroll area up -- without the glitches during reordering.
So instead of:
[tableView setContentInset:UIEdgeInsetsMake(-16, 0, 0, 0)];
Try:
[tableView setSectionHeaderHeight:-16.0];
This of course won't play well if you have content in section headers (or multiple sections in your table), but for single-section tables it seems to be a passable workaround.
One quick update since I don't have enough rep to comment yet: The original bug this is trying to work-around appears to be fixed on iOS 7. I wound up wrapping my fix in a version-checking conditional for iOS <7 devices.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With