Note that there are some explanatory texts on larger screens.

plurals
  1. POmoveRowAtIndexPath doesn't get called
    text
    copied!<p>My code doesn't enter the moveRowAtIndexPath part. But it enters into canMoveRowAtIndexPath. </p> <p>When I click minus, "delete" doesn't appear. How can I solve this? Thank you.</p> <p>ps:I try to make it work for not the tableview with the SearchDisplayController.</p> <p>In .h file : UITableViewDataSource,UITableViewDelegate,UISearchBarDelegate,UISearchDisplayDelegate</p> <pre><code> `/*viewdidload*/` self.editbtn addTarget:self action:@selector(toggleEditMode:) forControlEvents:UIControlEventTouchUpInside]; } -(void)toggleEditMode:(id)sender { if(self.alerjitableview.isEditing){ [self.alerjitableview setEditing:NO animated:YES]; [self.editbtn setTitle:@"Düzenle" forState:UIControlStateNormal]; }else{ [self.alerjitableview setEditing:YES animated:YES]; [self.editbtn setTitle:@"Bitti" forState:UIControlStateNormal]; } } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if(tableView== self.alerjitableview) return[hastaninalerjileri count]; else{ if(tableView == self.searchDisplayController.searchResultsTableView) if (isSearching) { return [tanilist count]; } else { return [list count]; } else return [favTanilar count]; } } - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { return YES; } - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { return YES; } - (void) tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)targetIndexPath { //if(tableView == self.searchDisplayController.searchResultsTableView) if(tableView== self.alerjitableview){ NSUInteger sourceIndex = [sourceIndexPath row]; NSUInteger targetIndex = [targetIndexPath row]; if (sourceIndex != targetIndex) { [hastaninalerjileri exchangeObjectAtIndex:sourceIndex withObjectAtIndex:targetIndex]; } } } - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UITableViewCellEditingStyleDelete) { if(tableView== self.alerjitableview){ [hastaninalerjileri removeObjectAtIndex:[indexPath row]]; // Animate deletion NSArray *indexPaths = [NSArray arrayWithObject:indexPath]; [self.alerjitableview deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationFade]; [self.alerjitableview reloadData]; } else { if (tableView == self.taniView) { [hastanintanilari removeObjectAtIndex:[indexPath row]]; // Animate deletion NSArray *indexPaths = [NSArray arrayWithObject:indexPath]; [self.taniTableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationFade]; } } } } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 50.0; } - (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } TaniModel *taniInfo =[[TaniModel alloc]init]; if (isSearching &amp;&amp; [tanilist count]) { taniInfo = [tanilist objectAtIndex:indexPath.row]; } else { taniInfo = [list objectAtIndex:indexPath.row]; } if(tableView == self.alerjitableview){ OrderAlerjiModel *alerjimodel =[hastaninalerjileri objectAtIndex:indexPath.row]; cell.textLabel.text = alerjimodel.Ad; if((indexPath.row % 2) ==0) cell.contentView.backgroundColor=[UIColor colorWithRed:241/256.0 green:237/256.0 blue:237/256.0 alpha:1.0]; return cell; } else{ if(tableView == self.searchDisplayController.searchResultsTableView){ cell.textLabel.text = taniInfo.Name; cell.textLabel.tag=[NSString stringWithFormat:@"%d",taniInfo.Id]; if((indexPath.row % 2) ==0) cell.contentView.backgroundColor=[UIColor colorWithRed:241/256.0 green:237/256.0 blue:237/256.0 alpha:1.0]; NSAttributedString *attributedText =[[NSAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@ ",cell.textLabel.text ] attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:14] }]; CGRect rect = [attributedText boundingRectWithSize:(CGSize){242/2, MAXFLOAT} options:NSStringDrawingUsesLineFragmentOrigin context:nil]; CGSize nameSize = rect.size; if (nameSize.height &lt;=25) cell.textLabel.numberOfLines=1; else if(nameSize.height&lt;=50) cell.textLabel.numberOfLines=2; else if(nameSize.height&lt;=100) cell.textLabel.numberOfLines=3; return cell; }else{ FavoriTaniModel *d = [favTanilar objectAtIndex:indexPath.row]; cell.textLabel.text =d.TaniName; cell.tag = [NSString stringWithFormat:@"%d",d.TaniId]; if((indexPath.row % 2) ==0) cell.contentView.backgroundColor=[UIColor colorWithRed:241/256.0 green:237/256.0 blue:237/256.0 alpha:1.0]; NSAttributedString *attributedText =[[NSAttributedString alloc]initWithString:cell.textLabel.text attributes:@{ NSFontAttributeName: [UIFont systemFontOfSize:14] }]; CGRect rect = [attributedText boundingRectWithSize:(CGSize){242/2, MAXFLOAT} options:NSStringDrawingUsesLineFragmentOrigin context:nil]; CGSize nameSize = rect.size; cell.textLabel.frame =CGRectMake(30, 0, 242, nameSize.height); if (nameSize.height &lt;=25) cell.textLabel.numberOfLines=1; else if(nameSize.height&lt;=50) cell.textLabel.numberOfLines=2; else if(nameSize.height&lt;=100) cell.textLabel.numberOfLines=3; return cell; } } } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if(tableView == self.taniTableView){ if(tableView == self.searchDisplayController.searchResultsTableView){ TaniModel *model=[tanilist objectAtIndex:indexPath.row]; NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@"0",@"Id",@"0",@"OrderId",[NSString stringWithFormat:@"%d",model.Id],@"TaniId",model.Name,@"Ad",@"1",@"OrderBy", nil]; OrderTaniModel *orderalerji = [[OrderTaniModel alloc]initWithDictionary:dict]; [hastanintanilari addObject:orderalerji]; [self.taniTableView reloadData]; [self.searchDisplayController.searchResultsTableView setHidden:TRUE]; } } } </code></pre> <p><img src="https://i.stack.imgur.com/fEj1t.png" alt="enter image description here"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload