Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selecting a UITableViewCell in Edit mode

If I create a UITableViewController - drilling down works as expected. If a user selects a cell and I implement 'didSelectRowAtIndexPath', the cell flashes blue and the next view shows up.

But, if I include an 'edit' button (self.navigationItem.rightBarButtonItem = self.editButtonItem), when the user clicks 'Edit' - the mode correctly changes (all the cells indent and paint an appropriate editingAccessory), ... BUT, the cells are no long 'selectable'.

IE: while in edit mode, when a user selects a cell, nothing is happening. No blue flash. No invocation of 'didSelectRowAtIndexPath', nothing.

When I open the iPhone example 'iPhoneCoreDataRecipes' (as provided in the SDK docs), sure enough, they have a RecipeDetailViewController - that, when put into edit mode, still allows you to drill down. I've downloaded and built their example and it works just fine. I can't seem to find any trickery in their code to enable this 'selectable cell when in edit mode behavior' but I'm just not getting it when I do it.

Thoughts?

Thanks for any time,

-Luther

like image 668
Luther Baker Avatar asked Aug 13 '09 00:08

Luther Baker


3 Answers

UITableView has a property allowsSelectionDuringEditing for this.

IMHO it should have been YES by default.

like image 133
NWCoder Avatar answered Nov 18 '22 16:11

NWCoder


You have to set the allowsSelectionDuringEditing property of UITableView to YES.

The default value is NO.

like image 38
Giorgio Avatar answered Nov 18 '22 18:11

Giorgio


It can be changed in Storyboard:

enter image description here

like image 3
avdyushin Avatar answered Nov 18 '22 17:11

avdyushin