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>;7-表格文本被截断_Ios_Iphone_Uitableview - Fatal编程技术网

iOS>;7-表格文本被截断

iOS>;7-表格文本被截断,ios,iphone,uitableview,Ios,Iphone,Uitableview,这是我的密码: - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ UIFont *cellFont; if(delegate.iPad){ cellFont= [UIFont fontWithName:@"Helvetica" size:28.0]; }else{

这是我的密码:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
        UIFont *cellFont;

        if(delegate.iPad){
            cellFont= [UIFont fontWithName:@"Helvetica" size:28.0];
        }else{
            cellFont= [UIFont fontWithName:@"Helvetica" size:12.0];
        }
        CGSize size = [cellText sizeWithAttributes:@{NSFontAttributeName: myFont}];

        // Values are fractional -- you should take the ceilf to get equivalent values
        CGSize labelSize = CGSizeMake(ceilf(size.width), ceilf(size.height));
        tableHeight2 = tableHeight2 + labelSize.height;


        NSStringDrawingContext *ctx = [NSStringDrawingContext new];
        NSAttributedString *aString = [[NSAttributedString alloc] initWithString:cellText];
        UITextView *calculationView = [[UITextView alloc] init];
        [calculationView setAttributedText:aString];
        CGRect textRect = [calculationView.text boundingRectWithSize:table2.frame.size options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:cellFont} context:ctx];
        return = textRect.size.height;
}

最后一行左右的文字由于某种原因被剪掉了,尽管它似乎正确地计算了高度。我遗漏了什么吗?

发生这种情况的两个原因:

1) 自动布局自动调整大小问题ie设置不正确

2)
heightForRowAtIndexPath
中返回的Height错误

解释:在这里,您应该使用(文本高度+顶部填充+底部填充)返回高度


我必须关闭autolayout,因为我使用的是ECSlidingViewController,这意味着当幻灯片菜单滑出时,它会调整表格的大小,使它们看起来很有趣。我试试另一个选项。哦,等等,我没有用标签,我用的是cell.textlab。我不知道如何包含您的修复。从indexpath获取单元格,然后使用单元格的textlabel
 return = textRect.size.height+(2*label.frame.origin.x);