UIView にいくつかの UITableView が並んでいて、全体を自動サイズ変更したいと考えています。私は init() メソッドで UIView を持っています:
// I don't know how big frontBack should be, so I'd like it to autosize
UIView *frontBack = [[UIView alloc] initWithFrame:CGRectZero];
frontBack.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
UITableView *table = [[UITableView alloc]
initWithFrame:CGRectMake(0, 0, r.size.width / 2, height) style:UITableViewStyleGrouped];
table.autoresizingMask = UIViewAutoresizingFlexibleHeight;
table.dataSource = model1;
[table reloadData];
[frontBack addSubview:table];
... (add second table similarly, except with model2)
...
controller.view = frontBack;
これは動作しません。テーブルの高さは 'height' ピクセルです (これは必要なサイズよりも小さく、テキストは切り取られています)。
UITableViews のサイズを変更するいくつかの方法を試しましたが、うまくいきませんでした
// contentSize is correct, but frame size does not change
[table reloadData];
table.frame.size.height = table.contentSize.height;
// contentSize is correct, but bounds does not change
[table reloadData];
table.bounds.size.height = table.contentSize.height;
// Nothing appears to change
[table setNeedsLayout];
[table layoutIfNeeded];
// Again, no change
[table sizeToFit];
ここで何か基本的なことが欠けていると思いますが、誰かがそれが何であるかを指摘できればありがたいです.