【发布时间】:2010-10-06 00:13:01
【问题描述】:
尝试创建一个充满按钮的简单表格,其中按钮是在运行时生成的;表格出现了,并且有正确的行数等,但行似乎是空的。
public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
{
// The NavItem class is a "Josh Bloch enum" with n ordered members
NavItem item = NavItem.ByOrder(indexPath.Row);
var cell = tableView.DequeueReusableCell(item.Name);
if (cell == null)
{
cell = new UITableViewCell(UITableViewCellStyle.Default, item.Name);
UIButton button = UIButton.FromType(UIButtonType.RoundedRect);
button.SetTitle(item.Name, UIControlState.Normal);
cell.ContentView.AddSubview(button);
// cell.TextLabel.Text = item.Name;
// cell.Accessory = UITableViewCellAccessory.DisclosureIndicator;
}
return cell;
}
没有按钮,注释掉的纯文本版本可以正常工作。
我是 iOS 的新手,所以我认为这里缺少关于组件大小、定位或布局的一些东西——有人知道它是什么吗?
【问题讨论】:
标签: uitableview ios uibutton xamarin.ios