【问题标题】:Enter data to a custom UITableViewCell向自定义 UITableViewCell 输入数据
【发布时间】:2012-02-01 08:47:17
【问题描述】:

我创建了一个自定义 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;
}

有什么建议吗?

【问题讨论】:

    标签: iphone uitableview xamarin.ios


    【解决方案1】:

    您必须将 cell 转换为您的 UITableViewCell 实现的实例才能访问自定义属性和方法。

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

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多