iphone - UITableViewCell 内旋转的 UITableView 未显示 initWithFrame : says to

标签 iphone ios uitableview

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

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的宽度设置为一个值>包含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 的宽度而不是变得困惑?

更新:

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

}

最佳答案

将当前的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/

相关文章:

iphone - 操作 AudioBuffer 的 mData 中的数据

iphone - 是否可以在没有按钮的情况下切换 View ?

ios - 如何在 Xcode 10 中设置对象的高度和宽度?如果我们设置值,它表示固定约束可能会导致裁剪

ios - 如何为不同的 iOS 应用配置文件包含不同的 plist

ios - UILabel 的滑动动画

ios - 如何让 UIlabel 动态地自动跨越多行。在具有多个 UIlabels 的 Tableview 单元格/ContentView 中

ios - 应用程序因 NSRangeException (NSMutableArray) 而终止

iphone - Cocos2d 按钮被点击后,定时器增加 3 秒

ios - 通过触摸 UITableView 的背景关闭键盘

iphone - 为本地通知选择自定义声音