0

我有一个 UITableViewController,它有一个 UITableViewCell 的子类,每个单元格都有一个 UITableView。我有两个 UITableViews 工作得很好。当我旋转它时,问题就来了。如果我将 tableViewInCell 的框架设置为比包含单元格的高度更大的宽度,那么它就会变得混乱。见下文。

tableView 的宽度设置为一个值 <= 包含 tableViewCell 的高度:

tableViewInCell = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 132, 132) style:UITableViewStylePlain];

tableView 的宽度设置为一个值 <= 包含 tableViewCell 的高度

tableView 的宽度设置为一个值 > 包含 tableViewCell 的高度:

tableViewInCell = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 132, 320) style:UITableViewStylePlain];

tableView 的宽度设置为一个值 > 包含 tableViewCell 的高度

如何让 tableViewInCell 填充包含 UITableViewCell 的宽度而不是乱线?

更新:

tableViewInCell = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 132) style:UITableViewStylePlain];

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

}
4

1 回答 1

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

}
于 2012-06-09T20:58:17.637 回答