7
votes

When I change my uitableview to edit mode, i'd like the user to be able to select a cell without the segue taking place. The segue was linked in the storyboard. Is there a way to disable the segue during edit mode?

I can't disable interaction with the cell during edit more because I need to pick up on the editing control (insert button) press.

2

2 Answers

13
votes

In your view controller, override:

- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender{
    return !self.isEditing;
}

Inside that method check if this is the correct segue, and verify the edit state. If the editing is on, return NO; otherwise, return YES.

2
votes

Swift 3+:

Assuming you've inherited from UITableViewController:

override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
    return !tableView.isEditing
}

Note this will disable all segues while editing. If you have more than one and you want some to remain enabled in edit mode, apply the appropriate logic within this function to return true or false as appropriate.