//自適應高度
- (void)chanageHeight
{
//誰在最下面用誰 也就是你最後一個控件
CGRect aRect1 = self.contentView.frame;
aRect1.size.height = self.backGroundImageV.frame.size.height+self.backGroundImageV.frame.origin.y;
self.contentView.frame = aRect1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
LCAboutBallTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[LCAboutBallTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.dataArray = [_dataArray objectAtIndex:[indexPath row]];//數據傳到cell裏
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
cell.backgroundColor = [UIColor clearColor];
}
[cell createView];
cell.collectionButton.tag = indexPath.row;
[cell.collectionButton addTarget:self action:@selector(collectionButton:) forControlEvents:UIControlEventTouchUpInside];
[cell chanageHeight]; //調用自適應方法
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
CGFloat cellHeight=0;
@autoreleasepool { //此處根據cell 返回總體高度
LCAboutBallTableViewCell *cell=(LCAboutBallTableViewCell *)[self tableView:tableView cellForRowAtIndexPath:indexPath];
cellHeight=cell.contentView.frame.size.height;
return cellHeight;
}
}