UITableViewCell
の高さを設定してください。セットアップできません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;
}
このコードは、これを与える:このような
方法は、私を助けていませんでした:SO
- (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
の非常に大きな高さに設定しても、変更されていません。上部のみが表示されます。
ストーリーボード – Birendra
@Birendraを使用して設定しようとしましたが、画面サイズによって高さが異なるためプログラムでセットアップしたいと考えています。 – Vyacheslav
@Birendra、私はストーリーボードを使用しようとしました。とにかく同じ結果。 – Vyacheslav