Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ios didselectrowatindexpath not called when in the editing mode [duplicate]

Tags:

ios

iphone

ios6

Hi when in the table view editing mode, the didselectrowatindexpath function is not called. Here are my code. Any wrong with my code ?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath  {
    if (self.tableView.editing == YES)   {
        NSLog(@"now in editing mode");
    }
    else {
        NSLog(@"now in normal mode");
    }
}

- (void)setEditing:(BOOL)editing animated:(BOOL)animated   {
    [super setEditing:editing animated:animated];
    // must be called first according to Apple docs
    [self.tableView setEditing:editing animated:animated];
}

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath   {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath   {
    return UITableViewCellEditingStyleNone;
}

- (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath  {
    return NO;
}

Please help.Thanks

like image 866
Jason lau Avatar asked Jul 15 '13 10:07

Jason lau


2 Answers

You have to set this property allowsSelectionDuringEditing of UITableView to TRUE to be able to select row while on Editing mode. So it should be

self.tableView.allowsSelectionDuringEditing=YES;
like image 157
iphonic Avatar answered Nov 01 '22 02:11

iphonic


I don't believe it is enabled by default, but you have to specify what selection should be allowed during editing, just as you would for non-editing selection. Use one of the two following lines depending on what you need.

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self.tableView setAllowsMultipleSelectionDuringEditing:YES];
    [self.tableView setAllowsSelectionDuringEditing:YES];
}
like image 27
Mick MacCallum Avatar answered Nov 01 '22 00:11

Mick MacCallum