ios - 在自定义单元格内动态添加标签
<p><p>我在自定义单元格中动态添加 UIlabels,每个标签之间的间隙没有正确对齐。所以,请帮我解决这个问题。</p>
<pre><code> 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;
;
</code></pre>
<p> <img src="/image/73lO9.png" alt="Please Check this screen"/> </p>
<pre><code> NSString *strfrom=[ 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.backgroundColor = ;
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>一步一步引用这个网址....</p>
<p> <a href="http://www.raywenderlich.com/73602/dynamic-table-view-cell-height-auto-layout" rel="noreferrer noopener nofollow">http://www.raywenderlich.com/73602/dynamic-table-view-cell-height-auto-layout</a> </p></p>
<p style="font-size: 20px;">关于ios - 在自定义单元格内动态添加标签,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/29648792/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/29648792/
</a>
</p>
页:
[1]