1

First off, sorry if this is a duplicated question but after reading several posts with similar issue, I wasn’t able to find a clear solution.

The problem is what the title states: I have a pretty basic tableview, with only one section and a tableheader. When I delete one row, the table header also gets swiped to the left at the same time with the row being deleted.

I guess the solution is to return false in canEditRowAtIndexPath when I know it is the header calling, but I don’t know how to differentiate it from the rest of rows.

I tried tableView.cellForRowAtIndexPath but didn’t work, I guess it is because the header cell is not really part of the tableview as the normal cells are. In fact, I don’t know how to get the indexPath of my header cell. I also thought about tagging the header cell but, again, I don’t know how to get it back in canEditRowAtIndexPath.

Many thanks in advance!!

David Lara
  • 51
  • 2
  • 11

2 Answers2

2

This may happen if you are using an UITableViewCell instead of an UIView in viewForHeaderInSection method. Please verify it.

If you have only one section and you don't really need a sticky header, you could also add the UIView to the tableView.tableViewHeader property. Please check https://stackoverflow.com/a/5442005/3211512 for an example.

allo86
  • 946
  • 1
  • 9
  • 23
0

I think, allo86 is right. Your header may be a UITableViewCell. However, I would suggest a little different approach. If you are having only one section then set an UIView on top of your Table view(outside of the table) but if you are going to have multiple sections, then set UIViews as headers accordingly for any section for which you want to have a header.

Natasha
  • 6,651
  • 3
  • 36
  • 58