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);

我在 iPhone 上的 _contentView 和 self.view 上的 _contentView 添加了一个 tableview 没有问题,但是在 iPad 上我不知道为什么当我为 table view 设置自动调整掩码时,它会增加宽度和高度......没有自动调整掩码很好用,但我需要为风景自动调整蒙版。如何解决这个问题?

带有自动调整大小的蒙版 带有自动调整大小的蒙版 没有自动调整大小的蒙版 没有自动调整大小的蒙版

4

1 回答 1

0

一旦尝试这个

_contentView.autoresizesSubviews = YES ;

希望这会奏效。

于 2015-12-11T06:09:06.033 回答