ios uitableview 刷新失败的问题。
程序员文章站
2022-03-28 09:29:11
...
我想更新到连接自定义单元格。我想要搜索时刷新表格单元格。我使用 reloadRowsAtIndexPaths 方法。这种方法的工作,但未更新的单元格。你能帮我吗
以下方法运行时,我搜索
-(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;
}
解决方法 1:
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationAutomatic];
推荐阅读
-
iOS中的UITableView的重用机制与加载优化详解
-
IOS 出现问题POST网络请求状态code:500的解决方法
-
快速解决低版本Xcode不支持高版本iOS真机调试的问题方法
-
IOS UITableView颜色设置的实例详解
-
IOS 开发之实现取消tableView返回时cell选中的问题
-
IOS UITableView和UITableViewCell的几种样式详细介绍
-
iOS tableView上拉刷新显示下载进度的问题及解决办法
-
iOS下拉刷新 UIScrollVie异常闪动问题
-
iOS系统和微信中不支持audio自动播放问题的解决方法
-
iOS 11 下适配UITableView 问题