0

私のコードはここにあります:

CGRect mainFrame = [UIScreen mainScreen].bounds;

_contentView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0.0, mainFrame.size.width, mainFrame.size.height-20)] autorelease];
_contentView.autoresizingMask = (UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);
_contentView.backgroundColor = [UIColor clearColor];
[self.view addSubview:_contentView];


self.tableView = [[[UITableView alloc] initWithFrame:_contentView.frame style:UITableViewStylePlain] autorelease];
[self.tableView setBackgroundColor:[UIColor clearColor]];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
[self.tableView setSeparatorColor:[UIColor clearColor]];
[_contentView addSubview:_tableView];
self.tableView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);

_contentView に tableview を追加し、self.view に _contentView を追加すると、iPhone では問題なく動作しますが、iPad では、テーブル ビューの自動サイズ変更マスクを設定すると幅と高さが増加する理由がわかりません...自動サイズ変更マスクなしでうまく動作します、しかし、風景用のマスクの自動サイズ変更が必要です。これを解決するには?

自動サイズ変更マスクあり 自動サイズ変更マスク 自動サイズ変更マスク付き なし マスクの自動サイズ変更なし

4

1 に答える 1

0

一度これを試してみてください

_contentView.autoresizesSubviews = YES ;

これがうまくいくことを願っています。

于 2015-12-11T06:09:06.033 に答える