我有一个UITableViewController,其子类为UITableViewCell,每个单元格中都有一个UITableView。我有两个UITableViews工作得很好。当我旋转它时会出现问题。如果我将tableViewInCell的框架设置为宽度大于包含单元格的高度,则它会变为heywire。见下文。
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的宽度而不是hewwire?
更新:
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];
}
答案 0 :(得分:1)
将您当前的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];
}