我已经使用了以下问题的解决方案来填充 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
但这是我在表格单元格中得到的
知道为什么会有差异吗?
最佳答案
使用您发布的附加代码,我会将其分成两个单独的标签:左对齐的文本作为一个标签,右对齐的是/否/数字作为另一个标签。这将使您能够实现所需的效果,而不必担心字母间距。
关于ios - 填充 NSString 在 UITableViewCell 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27409276/