Ios UITableViewCell自定义高度
我正在尝试为我的Ios UITableViewCell自定义高度,ios,swift,uitableview,autolayout,swift2,Ios,Swift,Uitableview,Autolayout,Swift2,我正在尝试为我的UITableViewCell设置自定义高度。在Xcode中,我给了它一个自定义高度,并添加了一个UImageView子视图,它看起来不错。但是在运行时,单元格的高度会回落到默认值,并且我的图像会被严重裁剪 我已经将代理设置为使用动态高度,并且在Xcode中为单元格提供了自定义高度,并且我的图像设置为纵横比填充。我不确定我还缺少什么 这是我的vc: func numberOfSectionsInTableView(tableView: UITableView) -> Int
UITableViewCell
设置自定义高度。在Xcode中,我给了它一个自定义高度,并添加了一个UImageView
子视图,它看起来不错。但是在运行时,单元格的高度会回落到默认值,并且我的图像会被严重裁剪
我已经将代理设置为使用动态高度,并且在Xcode中为单元格提供了自定义高度,并且我的图像设置为纵横比填充。我不确定我还缺少什么
这是我的vc:
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 2
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
switch indexPath.section {
case 0:
return UITableViewAutomaticDimension
default: ()
return 50
}
}
func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
switch indexPath.section {
case 0:
return 300
default: ()
return 50
}
}
当然,这不是一个很好且清晰的答案,但设置自动布局可能会有问题。通常很难在这里提供包含布局和约束的所有数据,因此您最好检查一些资料,如。然后检查您的代码。我认为记分板布局设置中存在一些问题,请根据此检查设置单元格并