当前位置: 首页 > news >正文

定位Section的FooterView

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

@interface ZZTestViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *myTableView;
@property (strong, nonatomic) NSArray *dataArray;
@property (strong, nonatomic) ZZTestFooterView *footerView;

@end

@implementation ZZTestViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initWithUI];
    // Do any additional setup after loading the view from its nib.
}

- (void)initWithUI {
    self.navigationItem.title = @"分类";
    _dataArray = @[@"I", @"II", @"II", @"IV"];
    [self initWithTableView];
    
}

- (void)initWithTableView {
    self.myTableView.dataSource = self;
    self.myTableView.delegate = self;
    [self.myTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cellId"];
    self.myTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    
}

#pragma mark UITableViewDelegate, UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return _dataArray.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 50;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 100;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    
    UIView *base = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 100)];

    _footerView = [[NSBundle mainBundle] loadNibNamed:@"ZZTestFooterView" owner:nil options:nil][0];
    
    //footerView的按钮tag回调
    __weak typeof(self) weakSelf = self;
    [_footerView selectCategory:^(NSInteger tag) {
        __strong typeof(weakSelf) strongSelf = weakSelf;
        [strongSelf seleWithCategory:tag withIndex:section];
    }];
    
    [base addSubview:_footerView];
    
    return base;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellId"];
    cell.textLabel.text = _dataArray[indexPath.section];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

#pragma mark footerView 的按钮点击
- (void)seleWithCategory:(NSInteger)tag withIndex:(NSInteger)index {
    //index-->section
    NSLog(@"%ld", index);
}

 

转载于:https://my.oschina.net/u/2519763/blog/1503423

相关文章:

  • 第十六周oj刷题——Problem I: 改错题:类中私有成员的訪问
  • 第2章第2节练习题3 使用队列模拟渡口管理
  • Zookeeper客户端Curator---Getting Started
  • [Step By Step]SAP HANA创建属性视图(Attribute View)
  • 如何在Linux上检测硬盘上的坏道和坏块
  • Linux高速下载工具——Axel
  • 低功耗M2M市场广阔 芯片设计如何降耗
  • 3.垃圾回收器
  • Debian下无root权限使用Python访问Oracle
  • bzoj 1860: [Zjoi2006]Mahjong麻将 题解
  • git使用点滴:如何查看commit的内容和git 获取最近一次提交的commit id
  • 美光Sun合作长寿命SLC闪存 100万次写入
  • OCZ新Summit系列固态硬盘强悍性能曝光
  • 用MAID 2.0降低存储费用
  • 为什么要创建开放源码的PlayScala社区?
  • 2018一半小结一波
  • centos安装java运行环境jdk+tomcat
  • CentOS从零开始部署Nodejs项目
  • CSS相对定位
  • ES6系统学习----从Apollo Client看解构赋值
  • Java多态
  • JDK9: 集成 Jshell 和 Maven 项目.
  • js对象的深浅拷贝
  • Lsb图片隐写
  • markdown编辑器简评
  • php的插入排序,通过双层for循环
  • SpiderData 2019年2月23日 DApp数据排行榜
  • thinkphp5.1 easywechat4 微信第三方开放平台
  • TypeScript实现数据结构(一)栈,队列,链表
  • WordPress 获取当前文章下的所有附件/获取指定ID文章的附件(图片、文件、视频)...
  • 不发不行!Netty集成文字图片聊天室外加TCP/IP软硬件通信
  • 成为一名优秀的Developer的书单
  • 电商搜索引擎的架构设计和性能优化
  • 给新手的新浪微博 SDK 集成教程【一】
  • 基于Mobx的多页面小程序的全局共享状态管理实践
  • 排序算法之--选择排序
  • 什么是Javascript函数节流?
  • 通过git安装npm私有模块
  • 推荐一个React的管理后台框架
  • 用quicker-worker.js轻松跑一个大数据遍历
  • 容器镜像
  • #调用传感器数据_Flink使用函数之监控传感器温度上升提醒
  • #多叉树深度遍历_结合深度学习的视频编码方法--帧内预测
  • (C语言版)链表(三)——实现双向链表创建、删除、插入、释放内存等简单操作...
  • (pytorch进阶之路)扩散概率模型
  • (附源码)spring boot北京冬奥会志愿者报名系统 毕业设计 150947
  • (黑马出品_高级篇_01)SpringCloud+RabbitMQ+Docker+Redis+搜索+分布式
  • (强烈推荐)移动端音视频从零到上手(下)
  • (三十五)大数据实战——Superset可视化平台搭建
  • (一)为什么要选择C++
  • (译) 理解 Elixir 中的宏 Macro, 第四部分:深入化
  • (译)2019年前端性能优化清单 — 下篇
  • (转)c++ std::pair 与 std::make
  • .NET CF命令行调试器MDbg入门(一)
  • .NET DataGridView数据绑定说明