[英]IOS UItableview reloadRowsAtIndexPaths refresh issue
I want to update to tableview custom cell. 我想更新到tableview自定义单元格。 I want to refresh table cell When I search. 当我搜索时,我想刷新表格单元格。 I use reloadRowsAtIndexPaths methods. 我使用reloadRowsAtIndexPaths方法。 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;
}
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationAutomatic];
Try changing UITableViewRowAnimationFade
to UITableViewRowAnimationNone
and let me know if that helps. 尝试将UITableViewRowAnimationFade
更改为UITableViewRowAnimationNone
,如果有帮助,请告诉我。
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. 我只是必须这样做,因为我在我的故事板中使用静态UITableView,似乎任何动画都将旧单元格移出视图并替换为新单元格。 This basically removes the cell from the table because the old cell and the new cell are the same object(my assumption). 这基本上从表中删除了单元格,因为旧单元格和新单元格是同一个对象(我的假设)。
From UITableView documentation : 从UITableView 文档 :
beginUpdates 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. 除非要插入,删除或选择行或节,否则不应使用此方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.