实际上我想将 detailtextlabel 的位置设置为垂直居中。 在我的应用程序 detailtextlabel 位置根据单元格的 TextLabel(主要标签)。即它的对齐方式是右上角。
UITableViewCell cell = new UITableViewCell(UITableViewCellStyle.Value1, cellIdentifier);
cell.TextLabel.LineBreakMode = UILineBreakMode.WordWrap;
cell.TextLabel.Lines = 0;
cell.TextLabel.Font = UIFont.PreferredCaption1;
cell.Accessory = UITableViewCellAccessory.DisclosureIndicator;
cell.TextLabel.Text = "some long text";
cell.DetailTextLabel.Text = childCount+"";
最佳答案
您将必须实现一个自定义表格单元格以使其按照您想要的方式进行布局。 TextLabel
和 DetailTextTabel
是自动定位的,很难轻易改变它们的位置。
我建议使用 iOS 自动布局在 Storyboard中创建单元格以定位 View 。您将为单元定义一个自定义类,为新标签定义一个导出。您将使用这些 socket 而不是 iOS 提供的默认 TextLabel
和 DetailsTextLabel
属性。
例如:
public UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{
var cell = tableView.DequeueReusableCell("YourCellID") as YourCell;
cell.Update(passSomethingIn); //This public method would update your outlets
return cell;
}
然后 YourCell
类将有一个 Update
方法来更改每一行的任何值。
关于ios - 如何在 Xamarin.iOS 中将 DetailTextLabel 垂直居中放置在 UITableView 的单元格中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26923888/