reloadRowsAtIndexPaths会闪一下解决方法

使用单纯的reloadRowsAtIndexPaths刷新tableview高度会导致页面上下闪动。

解决方法:

把该代码包在UIView的无动画block方法里就可以解决。

[UIView performWithoutAnimation:^{

                    [weakSelf.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];

                }];


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要修改 UITableView 中的 cell 内容,可以通过以下步骤: 1. 获取需要修改的 cell:可以通过 UITableView 的 cellForRowAtIndexpath 方法获取指定 indexPath 对应的 cell。 2. 修改 cell 内容:根据具体需求,可以修改 cell 中的文本、图像等内容。具体方式可以通过修改 cell 的 textLabel、detailTextLabel、imageView 等属性来实现。 3. 刷新 cell:在修改完 cell 内容后,需要调用 UITableView 的 reloadRowsAtIndexPaths 方法刷新对应的 cell。 下面是一个简单的示例代码,用于修改指定 indexPath 对应的 cell 的文本内容: ```obj-c - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath]; // 获取 cell 对应的数据模型 DataModel *model = self.dataArray[indexPath.row]; // 设置 cell 内容 cell.textLabel.text = model.title; cell.detailTextLabel.text = model.subTitle; cell.imageView.image = [UIImage imageNamed:model.imageName]; return cell; } - (void)updateCellContentAtIndexPath:(NSIndexPath *)indexPath withTitle:(NSString *)title subTitle:(NSString *)subTitle { // 获取需要修改的 cell UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; // 修改 cell 内容 cell.textLabel.text = title; cell.detailTextLabel.text = subTitle; // 刷新 cell [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; } ``` 在这个示例中,我们首先通过 cellForRowAtIndexPath 方法获取指定 indexPath 对应的 cell,并根据数据模型设置 cell 的文本、图像等内容。然后我们定义了一个 updateCellContentAtIndexPath 方法,用于修改指定 indexPath 对应的 cell 的文本内容。在这个方法中,我们先获取需要修改的 cell,然后根据新的文本内容修改 cell 的 textLabel 和 detailTextLabel 属性,最后调用 reloadRowsAtIndexPaths 方法刷新对应的 cell。 需要注意的是,这个示例中只是一个简单的实现,具体实现方式需要根据具体的业务需求进行调整。同时,在实现中还需要考虑到错误处理和数据模型的更新等问题。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值