Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/98.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 UITableViewAutomaticDimension_Ios_Uitableview - Fatal编程技术网

Ios UITableViewAutomaticDimension

Ios UITableViewAutomaticDimension,ios,uitableview,Ios,Uitableview,我有一个表视图,其中包含由代码创建的动态单元格在IOS 7中为了确保单元格完全显示,我覆盖了方法heightforrowatinexpath 在ios8中重写此方法似乎会使我的单元格一个接一个,大小都是67.0003 我不想为单元格创建自动布局,它们太复杂了,已经制作好了 有没有办法解决ios 8中的高度问题?UITableViewAutomaticDimension仅适用于自动布局。如果不使用自动布局,请不要使用类似 self.tableView.rowHeight = UITableView

我有一个表视图,其中包含由代码创建的动态单元格
在IOS 7中
为了确保单元格完全显示,我覆盖了方法
heightforrowatinexpath

在ios8中重写此方法似乎会使我的单元格一个接一个,大小都是67.0003

我不想为单元格创建自动布局,它们太复杂了,已经制作好了


有没有办法解决ios 8中的高度问题?

UITableViewAutomaticDimension仅适用于自动布局。如果不使用自动布局,请不要使用类似

self.tableView.rowHeight = UITableViewAutomaticDimension;

如果您可以提供控制器的代码,这将很有帮助。

方法heightforrowatinexpath没有问题,它在ios8中也能很好地工作 问题出在我的高度,因为我写了一个索引路径

CGSize size;
a bunch of ifs
size.height = something
在其他情况下,我有

size.height+= something

和size.height
在开始时并不总是0

如果您想要动态单元格高度,您需要先设置单元格的大小

例如: 要在每个tableview单元格中提供一些文本信息,首先需要根据计算单元格的高度,然后在heightForRowAtIndexPath中设置单元格的高度

     - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath: (NSIndexPath *)indexPath
{
    NSString* text= [yourArray objectAtIndex:indexPath.row];
    CGSize textSize= [text getTextSize];

    if (textSize<SomeMinValue)
    {
        textSize= CGSizeMake(cellWidth, SomeMinValue)
    }

    return textSize.height;

}
-(CGFloat)tableView:(UITableView*)tableView rowatinexpath的高度:(nsindepath*)indepath
{
NSString*text=[yourArray objectAtIndex:indexath.row];
CGSize textSize=[text getTextSize];

如果(textSize如何禁用它?让系统允许我进行计算?尝试设置self.tableView.estimatedRowHight=44;只需离开.rowHeight并覆盖heightForRowAtIndexPath。正如文章中提到的,在ios8中覆盖heightForRowAtIndexPath会使所有行都位于另一行之上。如果我不覆盖它们,它们将被覆盖都设置为67分了你能上传一些测试项目吗?