首页 > 其他 > 详细

自定义UITableViewSectionHeaderView与FooterView 使用注意与重用

时间:2016-03-09 19:05:46      阅读:712      评论:0      收藏:0      [点我收藏+]
  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;

}



本文出自 “11290238” 博客,请务必保留此出处http://11300238.blog.51cto.com/11290238/1749233

自定义UITableViewSectionHeaderView与FooterView 使用注意与重用

原文:http://11300238.blog.51cto.com/11290238/1749233

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!