@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);}