我已经使用以下问题的解决方案来填充NSString Padding NSString not working,但是在将此字符串添加到UITableViewCell之后,未正确填充单元格标签

这是我用于填充的代码

cell.textLabel.text = [NSString stringWithFormat:@"%@%@", [question stringByPaddingToLength:50
                                                                                    withString:@" "
                                                                               startingAtIndex:0], answer];


这是我在控制台上打印单元格文本时得到的

(lldb) po cell.textLabel.text
Where was the NTD PSU installed                   5

(lldb) po cell.textLabel.text
Estimate of cable run distance.                   5

(lldb) po cell.textLabel.text
Uploaded Picture of NTD PSU Location.             No


但是这是我在表格单元格中得到的



知道为什么会有区别吗?

最佳答案

使用您发布的其他代码,我将其分为两个单独的标签:左对齐的文本作为一个标签,右对齐的yes / no / number作为另一个标签。这样一来,您无需担心字母间距,即可获得想要的效果。

关于ios - 填充NSString在UITableViewCell中不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27409276/

10-14 20:42
查看更多