Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITableViewCell自定义高度_Ios_Swift_Uitableview_Autolayout_Swift2 - Fatal编程技术网

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
    }
}

当然,这不是一个很好且清晰的答案,但设置自动布局可能会有问题。通常很难在这里提供包含布局和约束的所有数据,因此您最好检查一些资料,如。然后检查您的代码。

我认为记分板布局设置中存在一些问题,请根据此检查设置单元格并