输入数据到自定义UITableViewCell

时间:2012-02-01 08:47:18

标签: iphone uitableview xamarin.ios

我创建了一个自定义UITableViewCell(我创建了一个扩展UITableViewCell的类)并创建了一个包含我的自定义单元格的xib文件。。一切都很好但我有以下问题。我创建了带有4个标签的自定义单元格,并将标签连接到Xcode 4中的代码。当调用创建表格的函数时,我无法访问标签。这里的代码。 `

// Customize the appearance of table view cells.
public override UITableViewCell GetCell (UITableView tableView,MonoTouch.Foundation.NSIndexPath indexPath)
{
    string cellIdentifier = "Cell";
    var cell = tableView.DequeueReusableCell (cellIdentifier);
    //cell = null;
    if (cell == null) {
        cell = new MyCustomCell();
        var views = NSBundle.MainBundle.LoadNib("MYCustomCell", cell, null);
        cell = Runtime.GetNSObject( views.ValueAt(0) ) as MyCustomCell;
    }

    return cell;
}

有什么建议吗?

1 个答案:

答案 0 :(得分:2)

您必须将cell投射到UITableViewCell实施的实例中才能访问自定义属性和方法。

您可能希望了解Miguel de Icaza自定义UITableViewCells的方法,并将它们与可在单元格外重用的UIViews结合使用。 你可以在这里找到这篇文章:http://tirania.org/monomac/archive/2011/Jan-18.html

相关问题