在UITableViewCell中旋转UITableView没有显示initWithFrame:所说的位置

时间:2012-06-09 19:00:52

标签: iphone ios uitableview

我有一个UITableViewController,其子类为UITableViewCell,每个单元格中都有一个UITableView。我有两个UITableViews工作得很好。当我旋转它时会出现问题。如果我将tableViewInCell的框架设置为宽度大于包含单元格的高度,则它会变为heywire。见下文。

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

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

Width of tableView set to a value <= height of containing tableViewCell

tableView的宽度设置为值&gt;包含tableViewCell的高度:

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

Width of tableView set to a value > height of containing tableViewCell

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

更新:

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

}

1 个答案:

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

}