IOS UItableview update problem reloadRowsAtIndexPaths

I want to update a custom tableview cell. I want to update a table cell when searching. I am using reloadRowsAtIndexPaths methods. This method works, but did not update the cell. Can you help me?

Below is the start method when searching

-(void)doSearchHotelName:(id)sender{ NSIndexPath *tmpIndexpath=[NSIndexPath indexPathForRow:1 inSection:0]; [self.tableV beginUpdates]; [self.tableV reloadRowsAtIndexPaths:[NSArray arrayWithObjects:tmpIndexpath, nil] withRowAnimation:UITableViewRowAnimationFade]; [self.tableV endUpdates]; } 

Below is a table of method methods

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *simpleTableIdentifier = @"Hotel_FilterSearchCell"; Hotel_FilterSearchCell_iPad *cell = (Hotel_FilterSearchCell_iPad *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]; if (cell == nil) { NSArray *nib ; nib = [[NSBundle mainBundle] loadNibNamed:@"Hotel_FilterSearchCell_iPad" owner:self options:nil]; cell = [nib objectAtIndex:0]; } else if ([indexPath row]==1) { if([SharedAppDelegate.filter_selected_hotels_list count]==[SharedAppDelegate.filter_hotels_list count]) [cell.cellExtraInfo setText:@"All(H)"]; else if ([SharedAppDelegate.filter_selected_hotels_list count]!=[SharedAppDelegate.filter_hotels_list count]) [cell.cellExtraInfo setText:[NSString stringWithFormat:@"%i %@",[SharedAppDelegate.filter_selected_hotels_list count],@"Selected(H)"]]; } cell.selectionStyle = UITableViewCellSelectionStyleNone; return cell; } 
+4
source share
3 answers
 [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationAutomatic]; 
+7
source

Try changing the UITableViewRowAnimationFade to UITableViewRowAnimationNone and let me know if this helps.

I just needed to do the same, because I use a static UITableView in my storyboard, and it seems like any animation moves the old cell out of sight and replaces the new cell. This basically removes the cell from the table, because the old cell and the new cell are the same object (my guess).

+1
source

From the UITableView documentation :

beginUpdates
Begin a series of method calls that insert, delete, or select lines and sections of the receiver.

You should not use this method unless you insert, delete, or select a row or section.

0
source

Source: https://habr.com/ru/post/1435448/


All Articles