0

我的应用程序使用 UITableview 来显示图像提要。API 一次只提供这么多图像,所以我希望 tableview 中的最后一个单元格是具有Load More Button. 为此,我创建了一个LoadMoreCell带有标识符的自定义单元格LoadCell

使用GetCell我做的方法:

    public override UITableViewCell GetCell (UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
    {
        // request a recycled cell to save memory
        FeedCell cell = tableView.DequeueReusableCell (cellIdentifier) as FeedCell;

        if(indexPath.Row >= tableItems.Count)
        {
            LoadMoreCell loadCell = tableView.DequeueReusableCell ("LoadCell") as LoadMoreCell;
            return loadCell;
        }
        //Set Date and title
        cell.SetInfo (ids[indexPath.Row], userID, tableItems [indexPath.Row]);
        cell.SetImage (images[indexPath.Row]);
        cell.parent = this.parent;
        return cell;
    }

这给了我一个底部的Load More Button单元格,但单元格的尺寸与 a 相同,而FeedCell不是 a 的较小尺寸LoadMoreCell

有人知道我的问题可能是什么吗?

4

2 回答 2

2

您可能需要在 UITableViewSource 中覆盖 GetHeightForRow

public override float GetHeightForRow (UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
{
     if (indexPath.Row >= tableItems.Count) {
           return loadMoreHeight;
     } else {
           return regularRowHeight;
     }
}
于 2013-05-29T21:47:32.813 回答
0

UITableViewDelegate 有一个方法 tableView:heightForRowAtIndexPath: 你可以在那里返回单元格的高度。

于 2013-05-29T21:46:18.360 回答