我在UITableViewSource
中使用填充格式化单元格。我有:
//cell declared somewhere in `UITableViewSource`
var name = rows[indexPath.Row].MachineName.PadRight(50);
我也试过这个:
var name = rows[indexPath.Row].MachineName.PadRight(50, ' ');
我有一些设置单元格文本:
cell.TextLabel.Text = "01234567" + " " + name + "01234567";
输出如下:
01234567 SomeNameHere 01234567
-------------------------------------------
01234567 SomeNameHere 01234567
--------------------------------------------
01234567 SomeOtherNameHere 01234567
--------------------------------------------
01234567 ShortName 01234567
---------------------------------------------
我检查了name
的长度,所有这些都是50,但是当它在我的设备上显示在单元格中时,它不会排成一行。 Xamarin,iOS,UITableViewCell
是否有特别之处 - 可能有所不同。
我的解决方法是使用XCode创建一个UITableViewCell,但如果可行的话会很好。
答案 0 :(得分:1)
尝试:
var name = rows[indexPath.Row].MachineName.PadRight(10, '\t');
答案 1 :(得分:0)
我最终使用@Jason建议的等宽字体,似乎Courier New是iOS中唯一可用的快速搜索。