hiwordls
hiwordls

Reputation: 781

IOS UItableview reloadRowsAtIndexPaths refresh issue

I want to update to tableview custom cell. I want to refresh table cell When I search. I use reloadRowsAtIndexPaths methods. This method work, But did not update cell. Can you help me please

Below method run When I searched

-(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 method table method

- (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;
}

Upvotes: 4

Views: 15782

Answers (3)

Brenden
Brenden

Reputation: 7908

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

I just had to do the same because I'm using a static UITableView in my storyboard and it seems any animation moves the old cell out of view and replaces with the new cell. This basically removes the cell from the table because the old cell and the new cell are the same object(my assumption).

Upvotes: 1

Rajneesh071
Rajneesh071

Reputation: 31073

[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationAutomatic];

Upvotes: 7

Aniruddh
Aniruddh

Reputation: 7668

From UITableView documentation:

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

You should not use this method unless you are inserting, deleting or selecting a row or a section.

Upvotes: 0

Related Questions