【问题标题】:rotated UITableView within UITableViewCell not showing where initWithFrame: says toUITableViewCell 中的旋转 UITableView 未显示 initWithFrame: 的位置
【发布时间】:2012-06-09 19:00:51
【问题描述】:

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

tableView 的宽度设置为一个值

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

}

【问题讨论】:

  • 如果将 (132, 320) 更改为 (320, 132) 会发生什么
  • 在问题中查看我的屏幕截图更新。
  • 你能发布一些关于你如何旋转桌子的代码
  • 发布了在 initWithStyle:reuseIdentifier: 方法中调用的 setupTableView: 方法的代码。
  • 调用您发布的新代码会破坏视图吗?

标签: iphone ios uitableview


【解决方案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];

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-24
    • 2012-05-26
    • 1970-01-01
    相关资源
    最近更新 更多