我在自定义单元格中动态添加 UIlabels,每个标签之间的间隙没有正确对齐。所以,请帮我解决这个问题。
cell.lblObj.numberOfLines=0;
cell.lblObj.lineBreakMode = NSLineBreakByWordWrapping;
CGSize maximumLabelSize = CGSizeMake(170,100);
CGSize expectedLabelSize = [strfrom sizeWithFont:cell.lblObj.font
constrainedToSize:maximumLabelSize
lineBreakMode:NSLineBreakByWordWrapping];
CGRect newFrame = cell.lblObj.frame;
newFrame.size.height = expectedLabelSize.height;
cell.lblObj.frame = newFrame;
cell.lblObj.text=strfrom;
[cell.lblObj sizeToFit];
NSString *strfrom=[[mtblarray objectAtIndex:indexPath.row] valueForKey"source"];
cell.lblfrom.numberOfLines=0;
cell.lblfrom.lineBreakMode = NSLineBreakByWordWrapping;
CGSize maximumLabelSize = CGSizeMake(170,100);
CGSize expectedLabelSize = [strfrom sizeWithFont:cell.lblfrom.font
constrainedToSize:maximumLabelSize
lineBreakMode:NSLineBreakByWordWrapping];
CGRect newFrame = cell.lblfrom.frame;
newFrame.size.height = expectedLabelSize.height;
cell.lblfrom.frame = newFrame;
cell.lblfrom.text=strfrom;
[cell.lblfrom sizeToFit];
cell.lblfrom.backgroundColor = [UIColor redColor];
一步一步引用这个网址....
http://www.raywenderlich.com/73602/dynamic-table-view-cell-height-auto-layout
关于ios - 在自定义单元格内动态添加标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29648792/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |