iphone - Can't select UITableViewCell when TableView setEditing is set -


i want able select multiple rows default mail app shown below:

enter image description here

i have button called edit calls

[self.mytableview setediting:yes animated:yes] 

enter image description here

the edit button shows circles on left of cells mail app shown above. however, when select 1 of rows, nothing happens. red checkmark not appear in circle expect. why isn't red checkmark appearing?

#pragma mark - uitableviewdatasource methods  - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:@"myidentifier"];      if (cell == nil) {         cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstylesubtitle reuseidentifier:@"myidentifier"];     }      cell.textlabel.text = @"hey";      return cell; }  - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section {     return 3; }  #pragma mark - uitableviewdelegate methods  - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {     [tableview deselectrowatindexpath:indexpath animated:yes]; }  - (uitableviewcelleditingstyle)tableview:(uitableview *)tableview editingstyleforrowatindexpath:(nsindexpath *)indexpath {     return 3; }  #pragma mark - private methods  - (ibaction)editbuttontapped:(id)sender {     if (self.mytableview.editing) {         [self.mytableview setediting:no animated:yes];     }     else {         [self.mytableview setediting:yes animated:yes];     } } 

you have explicitly set selection enabled during editing mode:

[self.tableview setallowsselectionduringediting:yes]; 

or

[self.tableview setallowsmultipleselectionduringediting:yes]; 

according docs: these properties set no default.

if value of property yes , users can select rows during editing. default value no. if want restrict selection of cells regardless of mode, use allowsselection.

additionally, following snippet of code may causing problems selection because deselects row it's been selected.

- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath  {     [tableview deselectrowatindexpath:indexpath animated:yes]; } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -