What i want to achieve
I have a custom UITableViewCell with a UITextField for in-place editing. The cell's field should be enabled while the UITableView is in edit mode, but NOT while confirmation of deleting the cell is displayed.
How do i achieve this
I subclassed UITableViewCell and overrided its willTransitionToState method:
- (void)willTransitionToState:(UITableViewCellStateMask)state { [super willTransitionToState:state]; self.nameField.enabled = !(state & UITableViewCellStateShowingDeleteConfirmationMask) && (state & UITableViewCellStateEditingMask); }
Problem
I'm 90% from there.
' willTransitionToState ' is called after the user clicks the "-" button of the cell. A confirmation message is displayed, and my text box is disabled as desired. But what if the user decides not to delete the cell and hides the confirmation of deletion by checking the right? In this case, 'willTransitionToState' is not called.
As a result, my text box is stuck in a disabled state, although it should be turned on when confirmation of deletion is hidden. You might think that given the fact that the " UITableViewCellStateShowingDeleteConfirmationMask " flag exists, " willTransitionToState " will be called symmetrically, but that doesn't seem to be the case.
UPDATE
It seems the UITableViewCell ' showingDeleteConfirmation ' property always gives the correct result. Therefore, theoretically, I could showingDeleteConfirmation over each cell that calls " showingDeleteConfirmation ", and accordingly enable or disable each text field. It is inefficient and kludgy. I am considering reporting a " willTransitionToState " error, but I need more data. Has anyone else encountered this problem?
04/29/2014
Apple confirms that this is a mistake. To date, the error report is still open.
ios cocoa-touch uitextfield uitableview
skedastik
source share