Question

I'm trying to implement a user interface scenario very similar to the stock mail app. My table is set to be single selection. I used the control-drag thing to create a push segue from my cell to another view controller. So far, all great.

Now I've added a button which sets [self.tableView setEditing: YES animated: NO]. Like the mail app, I want to know be able to select some of them, and then operate on them with the toolbar at the bottom. I set the Editing attribute to Multiple Selection During Editing in the storyboard editor.

What happens when I enter the edit mode, is that it indents, and I get selection graphics for free already! BUT... when I press the first one, it selects it and then does the push segue. Is there an elegant way to make it push my details controller when it's in normal mode, but just toggle the selection state when it's in editing mode?

Having typed that... it occurs to me that I could add some indirection here. I bind the selection event to my controller, and then depending on whether the tableView.isEditing I either programmatically push the segue, or just toggle the selection. Is that the right way to do this? Or should I be doing something different?

Was it helpful?

Solution

when entering edit mode, set a class property BOOL editMode = YES. then in didSelectRowForIndexPath check if editMode == YES and then do nothing to select more cells, if NO start your segue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top