ios - 对于 viewForHeaderInSection 中的自定义单元格,重新加载特定的 viewForHeaderInSection IOS

标签 ios objective-c uitableview

如果 viewForHeaderInSection 中的自定义单元格重新加载特定的 viewForHeaderInSection IOS,我想重新加载 viewForHeaderInSection。

我使用了以下代码

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

但整个部分将重新加载

我也通过创建自定义 View 尝试了以下操作

SearchHeaderView 是自定义 View

  - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{

            lblPrice_Header.text = [NSString stringWithFormat:@"%d",cartSum] ;
            return SearchHeaderView;

        }

 -(void)cartSum :(id)sender{
   .....
   .......
    =======================================
     cartSum =cartSum+[[subArray objectAtIndex:j]  intValue]*price;

        UIView *headerVw = [self.tableView headerViewForSection:section];
        [headerVw setNeedsDisplay];
        [headerVw setNeedsLayout];

    }

但它不会重新加载该部分。

我的部分标题如下所示

enter image description here

我已经检查了以下链接

Reloading tableView header in ios7

Changing UITableView's section header/footer title without reloading the whole table view

最佳答案

你可以尝试这样的事情:

UIView *headerVw = [YOURTABLEVIEW headerViewForSection:section];
[headerVw setNeedsDisplay];
[headerVw setNeedsLayout];

注意:

  • 要处理特定 View ,您也可以定义标签

希望它对你有用。

关于ios - 对于 viewForHeaderInSection 中的自定义单元格,重新加载特定的 viewForHeaderInSection IOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31692692/

相关文章:

objective-c - MKPinAnnotationView 标注未显示

objective-c - 当从 XIB 加载 viewController 时,自动布局可以工作,但从 Storyboard 加载时,自动布局不起作用

iphone - 在动画期间访问 UIView 的当前位置

ios - 仅在可见单元格上播放视频

ios - 圆形 View 上的 UIGestureRecognizer

ios - 为什么使用 Storyboard在 UIScrollView 中不显示内容

ios - 为什么 AVSampleBufferDisplayLayer 停止显示从 AVCaptureVideoDataOutput 的委托(delegate)中获取的 CMSampleBuffers?

ios - 协议(protocol)实现中的 IBOutlet

swift - 无法将 iCloud 数据加载到 UITableView 中

ios - 任何与 Facebook iOS SDK 解除好友关系的方法