2016-12-12 17 views
1

私はカスタムセルPVIssueTypeSectionHeaderCellを作成し、このコードのヘッダビューでContentViewためのサブビューとして追加:iOSのUITableViewHeaderFooterView.ContentViewサブビューで自動サイズ変更のカスタムセル幅

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); 

    var headerView = tableView.DequeueReusableHeaderFooterView(HeaderFooterViewKey); 

    if (headerView == null) 
    { 
     headerView = new UITableViewHeaderFooterView(HeaderFooterViewKey); 
    } 

    headerView.ContentView.AddSubview(cell); 

    return headerView; 
} 

しかし、カスタムセルの幅がありません以下の画像でわかるように、自動サイズ変更はしません。

これはiPadのランドスケープモードとiPhoneのポートレートモードである:

ipad landscape/iphone portrait

この1つはiPadのポートレートモードである間:にする方法

ipad portrait mode

カスタムセルの幅は自動的に変更されますか?

答えて

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; 
} 
関連する問題