我有一个 UITableViewController ,它是 UITableViewCell 的子类,每个单元格中都有一个 UITableView 。我的两个 UITableView 都工作得很好。当我旋转它时,问题就出现了。如果我将 tableViewInCell 的框架设置为大于包含单元格的高度的宽度,那么它就会变得困惑。见下文。
tableView 的宽度设置为一个值 <= 包含 tableViewCell 的高度:
tableViewInCell = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 132, 132) style:UITableViewStylePlain];
tableView的宽度设置为一个值>包含tableViewCell的高度:
tableViewInCell = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 132, 320) style:UITableViewStylePlain];
如何让 tableViewInCell 填充包含的 UITableViewCell 的宽度而不是变得困惑?
更新:
tableViewInCell = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 132) style:UITableViewStylePlain];
更新2:这是我设置tableViewInCell的方法。
-(void)setupTableView {
tableViewInCell = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 132) style:UITableViewStylePlain];
[tableViewInCell setDelegate:self];
[tableViewInCell setDataSource:self];
tableViewInCell.transform = CGAffineTransformMakeRotation(-M_PI * .5);
[self addSubview:tableViewInCell];
}
最佳答案
将当前的setupTableView
更改为
-(void)setupTableView {
tableViewInCell = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 132 , 320) style:UITableViewStylePlain];
tableViewInCell.transform = CGAffineTransformMakeRotation(-M_PI * .5);
tableViewInCell.frame = CGRectMake(0, 0, 320, 132);
[tableViewInCell setDelegate:self];
[tableViewInCell setDataSource:self];
[self addSubview:tableViewInCell];
}
关于iphone - UITableViewCell 内旋转的 UITableView 未显示 initWithFrame : says to,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10963741/