简体   繁体   中英

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

UITableView has a property allowsSelectionDuringEditing for this.

IMHO it should have been YES by default.

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

The default value is NO .

It can be changed in Storyboard:

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM