iOS在UITableViewHeaderFooterView.ContentView子视图中自动调整自定义单元格宽度

时间:2016-12-12 11:22:21

标签: ios iphone ipad xamarin.ios uitableviewsectionheader

我创建了一个自定义单元格jQuery(document).ready(function($){ $(".lightbox-trigger").click(function(){ console.log( $(this).data('large-thumb') ); console.log( $(this).html() ); }); }); ,并使用以下代码在标题视图中将其添加为PVIssueTypeSectionHeaderCell的子视图:

ContentView

但是,自定义单元格的宽度不会自动调整大小,如下图所示。

这是在iPad横向模式和iPhone纵向模式下:

ipad landscape/iphone portrait

此版本处于iPad纵向模式:

ipad portrait mode

如何让自定义单元格自动调整其宽度?

1 个答案:

答案 0 :(得分:0)

我终于通过ContentView直接返回自定义单元格GetViewForHeader来使其成功。

public override UIView GetViewForHeader(UITableView tableView, nint section)
{
    var cell = (PVIssueTypeSectionHeaderCell)tableView.DequeueReusableCell(HeaderCellKey);
    if(cell == null)
    {
        cell = PVIssueTypeSectionHeaderCell.Create();
    }

    cell.ViewModel = this.GroupedIssueTypesFilter.ElementAt((int)section);

    return cell.ContentView;
}