博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
定位Section的FooterView
阅读量:7079 次
发布时间:2019-06-28

本文共 2502 字,大约阅读时间需要 8 分钟。

hot3.png

@interface ZZTestViewController ()
@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

你可能感兴趣的文章
TODO
查看>>
web 端即时通讯
查看>>
jmeter代理录制的方法
查看>>
Windows7环境下MongoDB安装和配置
查看>>
百度搜索框自动补全
查看>>
通过html5 touch事件封装手势识别组件
查看>>
PHP面试题集
查看>>
Day 1
查看>>
C#中的委托,匿名方法和Lambda表达式
查看>>
模拟鼠标点击
查看>>
quartz 核心概念
查看>>
linux环境中安装NRPE插件执行远程"本地资源"检查?NRPE安装?
查看>>
看博客学学Android(四)
查看>>
eclipse中SVN报错解决
查看>>
SPOJ - PLSQUARE Palin Squar(hash+回文串)
查看>>
C#类的使用
查看>>
SparseBooleanArray.clone()报错的问题
查看>>
linux启动应用时出现bad interpreter:No such file or directory的原因
查看>>
linux io的cfq代码理解一
查看>>
Life of Pi
查看>>