// // BaoGaoDownView.m // Ifish // // Created by imac on 16/8/29. // Copyright © 2016年 lianxiang. All rights reserved. // #import "BaoGaoDownView.h" #import "BaoGaoDownViewCell.h" @implementation BaoGaoDownView - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code } return self; } -(void)layoutSubviews{ [self initTab]; } -(void)initTab{ self.tab = [[UITableView alloc] init] ; self.tab.frame = CGRectMake(0, 12.0, self.frame.size.width, self.frame.size.height); self.tab.delegate = self; self.tab.dataSource = self; [self addSubview:self.tab]; } #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [self.titles count]; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return (self.frame.size.height - 12) /4; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { BaoGaoDownViewCell *cell =[tableView dequeueReusableCellWithIdentifier:@"BaoGaoDownViewCell"]; if (!cell) { cell = [[[NSBundle mainBundle] loadNibNamed:@"BaoGaoDownViewCell" owner:self options:nil]lastObject]; } cell.pingfenLabel.text = self.titles[indexPath.row]; cell.fenlabel.text = [NSString stringWithFormat:@"%@分", self.fenArr[indexPath.row]]; return cell; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ [tableView deselectRowAtIndexPath:indexPath animated:YES]; [self.delegate didBaoGaoViewIndex:indexPath]; } @end