I have a UITableViewController subclass. I set self.editing = YES
at the end of the viewDidLoad
method, but when the table is displayed the little red 'delete' icon does not appear next to each row.
Then, I added an edit button to the navigation item:
self.navigationItem.rightBarButtonItem = self.editButtonItem;
When I launch the application now, it starts in edit mode (I can tell because the edit button says 'done') but, again, the delete icons don't appear. Then if I toggle it with the edit button twice (once to turn it off, then once to turn it on), the red delete icons appear.
So, my question is: why aren't the table cells displaying correctly when first displayed? I've tried moving the self.editing = YES
line to other places in the code, like in the init
function or the viewWillAppear
function, but no dice. It seems like this is a result of funny ordering somewhere (e.g. table cells initialized before editing is set, or something), but I can't figure it out; running the debugger shows that the viewDidLoad
call happens before cellForRowAtIndexPath
, as one would expect.
Other notes:
- Yes, I am having
editingStyleForRowAtIndexPath
returnUITableViewCellEditingStyleDelete
. But from debugging I've verified that that function is not even called after the first load. (It gets called after I toggle editing mode twice.)