美文网首页
UITableVIewHeadFootView使用注意

UITableVIewHeadFootView使用注意

作者: chushen61 | 来源:发表于2020-05-28 10:21 被阅读0次

项目某个功能 想到用head使用 好久没用 将- (UIView*)tableHeaderView:(UITableView*)tableViewsection:(NSInteger)section  这个方法用错了,导致不显示 经过一番查找- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 改回此方法,特此做记录更正TableViewHeadFootView使用

1、创建UITableViewHeaderFooterView的子类,可使用继承所有类集成此类

使用XIB创建 

........

纯代码创建

-(instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier

{

 if (self = [super initWithReuseIdentifier:reuseIdentifier]) {

    }

 return self;

}

纯代码创建,重写initWithReuseIdentifier方法,在该方法中添加内容。

2.控制器中实现代理方法

- (void)viewDidLoad {

   [super viewDidLoad];

 // Do any additional setup after loading the view.

//XIB创建注册方式

[self.tableView registerNib:[UINib nibWithNibName:@"SectionHeader" bundle:nil] forHeaderFooterViewReuseIdentifier:@"sectionHeader"];

//代码创建 注册方式    

//[self.tableView registerClass:[ZYSectionHeader class] forHeaderFooterViewReuseIdentifier:@"sectionHeader"];

}

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

 static NSString *reuseId = @"sectionHeader";

 SectionHeader *header = (SectionHeader *)[tableView dequeueReusableHeaderFooterViewWithIdentifier:reuseId];

 return header;

}

相关文章

  • UITableVIewHeadFootView使用注意

    项目某个功能 想到用head使用 好久没用 将- (UIView*)tableHeaderView:(UITabl...

  • 小白如何使用Metamask?

    最近梳理了一下 Metamask 使用方法。仅供个人研究使用,内容不作为任何使用建议。 注意!注意!注意!重要的事...

  • swift基础语法(函数)

    一、函数的基本使用 二、函数的使用注意 --- 参数名 三、函数的使用注意 --- 函数类型 四、函数嵌套

  • RACCommand使用注意

    RACCommand使用注意

  • Fastjson 使用注意

    将object转为Json时避免出现"$ref" SerializerFeature.DisableCircula...

  • componentsSeparatedByString使用注意

    注意:如果content内容为空,以逗号区分的时候。会生成一个空字符串的数组。数组内有一个空的字符串。这样会导致一...

  • ajax使用注意

    新版jQuery使用ajax: 旧版jQuery使用ajax:

  • Mysql 使用注意

    Mysql中不等于过滤null 代码段1 没办法更新 NULL 数据, 需要使用代码段2 limit分页,数据重复...

  • xml使用注意

    1、我用xml来干什么? 用来记录一些应用包名、及包名对应的一些属性。 2、我的xml文件要直接放在apk中,但有...

  • SVN使用注意

    2016.5.27 每次改代码之前先把代码update一下再改。改完了提交 用SVN提交代码的时候, 新增文件,要...

网友评论

      本文标题:UITableVIewHeadFootView使用注意

      本文链接:https://www.haomeiwen.com/subject/djjoahtx.html