UITableViewCell的自我大小的单元格在iOS8.2中运行良好,但是当我更新Xcode6.3时,它不起作用.
谁能告诉我原因?
override fun viewDidLoad() {
super.viewDidLoad()
self.tableView.rowHeight = UITableViewAutomaticDimension
}
Run Code Online (Sandbox Code Playgroud)


我刚刚在iOS 8.3版本上测试了我的演示代码,它已经破了.
它只能使用以下代码...
- (void)viewDidLoad
{
[super viewDidLoad];
self.tableView.estimatedRowHeight = 100;
// set cell values...
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewAutomaticDimension;
}
Run Code Online (Sandbox Code Playgroud)
如果我尝试放,tableView.rowHeight = UITableViewAutomaticDimension那么它不起作用.
确保设置estimatedRowHeight,然后使用heightForRow方法设置自动维度.
编辑
可能是因为你的tableview不是静态的尝试删除行... self.tableView.estimatedRowHeight = 100;并使用...
- (CGFloat) tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 100;
}
Run Code Online (Sandbox Code Playgroud)
只是一个猜测......
我认为在Swift中这是......
override func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 100
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2399 次 |
| 最近记录: |