繁体   English   中英

UITableview单元格高度在IOS7中不起作用

[英]UITableview Cell height not working in IOS7

我的问题类似于这个 SO问题。 我的UITableViewCell Height可以在IOS8上完美运行。 IOS7问题增加了,但内容没有显示。

我的代码是:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
long hightmain=0;

    if(selectIndex && indexPath.section == selectIndex.section)
    {

        NSString * myString = [description_vegetable_array objectAtIndex:indexPath.section];
        CGSize labelSize = [myString sizeWithFont:[UIFont systemFontOfSize:15]  constrainedToSize:CGSizeMake(190, MAXFLOAT) lineBreakMode:NSLineBreakByWordWrapping];
        hightmain=labelSize.height+120;

        if (hightmain<=140)
        {
             btn11.frame=CGRectMake(240,100,70,17);
             Description_LBL.frame=CGRectMake(127, 0, 190, 140);
             BGImage.frame=CGRectMake(0, -3, 320, 140);
        }
        else
        {                               
            [btn11 setTitle:@"Less Info" forState:UIControlStateNormal];
            btn11.frame=CGRectMake(240,hightmain-30,70,17);
            Description_LBL.frame=CGRectMake(127, -20, 190, hightmain);
            BGImage.frame=CGRectMake(0, -3, 320, hightmain);
            return hightmain;
        }
    }
    else
    {
        return 140;
    }
}

Description_LBL.frame=CGRectMake(127, 0, 190, 140); 我的标签高度增加,但文本不显示..在IOS8中可以正常工作,但IOS7不能正常工作

使用boundingRectWithSize:哪些NSString公共方法根据字符串值计算大小。

[testString boundingRectWithSize:CGSizeMake([UIScreen mainScreen].bounds.size.width,MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]} context:nil]

注意:sizeWithFont:在iOS 7.0中已弃用

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM