Domanda

I am using padding in my UITableViewSource to format a cell. I have:

//cell declared somewhere in `UITableViewSource`

var name = rows[indexPath.Row].MachineName.PadRight(50);

I have tried this as well:

var name = rows[indexPath.Row].MachineName.PadRight(50, ' ');

I have some set the cell text:

cell.TextLabel.Text = "01234567" + " " + name + "01234567";

The output looks like:

01234567 SomeNameHere           01234567
-------------------------------------------
01234567 SomeNameHere           01234567
--------------------------------------------
01234567 SomeOtherNameHere         01234567
--------------------------------------------
01234567 ShortName            01234567
---------------------------------------------

I have checked the length of name and all of them are 50 but when its shown on my device in the cell it doesn't line up. Is there something special with Xamarin, iOS, UITableViewCell - something that may be different.

My work around for this would be to create a UITableViewCell using XCode but it would be nice if this could work.

È stato utile?

Soluzione 2

I ended up using a monospaced font as suggested by @Jason and it seems Courier New is the only one available in iOS just from my quick search.

Altri suggerimenti

Try:

var name = rows[indexPath.Row].MachineName.PadRight(10, '\t');
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top