请帮我设置UITableViewCell
高度。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *simpleTableIdentifier = @"SimpleTableItem";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
UILabel *l0, *l1;
if (cell == nil) {
CGRect f = tableView.frame;
float sc0 = pow(dt.PHI_1, 3.f);
float sc1 = 1. - sc0;
CGRect z =CGRectMake(0, 0, 0, 0);//f.size.height
CGRect r =CGRectMake(0, 0, f.size.width, f.size.height / 26.f);
CGRect r0 =CGRectMake(0, 0, f.size.width * sc0, f.size.height / 26.f);
CGRect r1 =CGRectMake(f.size.width * sc0, 0, f.size.width * sc1, f.size.height / 26.f);
cell = [[UITableViewCell alloc] initWithFrame:r]
l0 = [[UILabel alloc] initWithFrame:r0];
l0.tag = 100;
[cell addSubview:l0];
l1 = [[UILabel alloc] initWithFrame:r1];
l1.tag = 101;
[cell addSubview:l1];
[cell.textLabel setFrame:z];
[cell.imageView setFrame:z];
[cell setFrame:r];
[cell.backgroundView setFrame:r];
} else {
l0 = (UILabel *)[self.view viewWithTag:100];
l1 = (UILabel *)[self.view viewWithTag:101];
}
cell.backgroundColor = [[UIColor alloc]initWithWhite:.0f alpha:0.f];
cell.imageView.hidden = YES;
cell.textLabel.hidden = YES;
[l0 setText:@"B"];
l0.backgroundColor = [UIColor yellowColor];
[l1 setText:@"TEXT"];
l1.backgroundColor = [UIColor redColor];
return cell;
}
这段代码给出了这个:
这样的方法对我没有帮助:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
CGRect f = tableView.frame;
return f.size.height / 26.f;
}
所以,如果我将高度设置得更小。也就是说,f.size.height / 26.f
我有一个透明的酒吧。
UITableView
定义:
table = [[UITableView alloc] initWithFrame:CGRectMake(x,y,w,h)];
table.dataSource = self;
[table setTag:1];
[self.view addSubview:table];
请为我提供一种设置单元高度的方法。如果我设置了非常大的高度,UITableViewCell
它也不会被修改 - 只显示顶部。