Iphone IOS UItableview重新加载RowsatindExpaths刷新问题
我想更新到tableview自定义单元格。我想在搜索时刷新表格单元格。我使用重载rowsatindexpaths方法。此方法有效,但未更新单元格。你能帮我吗 下面是我搜索时运行的方法Iphone IOS UItableview重新加载RowsatindExpaths刷新问题,iphone,ios,uitableview,Iphone,Ios,Uitableview,我想更新到tableview自定义单元格。我想在搜索时刷新表格单元格。我使用重载rowsatindexpaths方法。此方法有效,但未更新单元格。你能帮我吗 下面是我搜索时运行的方法 -(void)doSearchHotelName:(id)sender{ NSIndexPath *tmpIndexpath=[NSIndexPath indexPathForRow:1 inSection:0]; [self.tableV beginUpdates]; [self.ta
-(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];
}
下表方法
- (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;
}
从UITableView:
开始更新开始一系列方法调用,以插入、删除或选择接收方的行和节
除非插入、删除或选择行或节,否则不应使用此方法。请尝试将
UITableViewRowAnimationFade
更改为UITableViewRowAnimationNone
,如果有帮助,请告诉我
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationAutomatic];
我也不得不这么做,因为我在故事板中使用了静态UITableView,似乎任何动画都会将旧单元格移出视图,并替换为新单元格。这基本上会从表中删除单元格,因为旧单元格和新单元格是同一个对象(我的假设)。找到解决方案了吗?