2016-12-12 3 views
1

내가 정의 세포 PVIssueTypeSectionHeaderCell을 만들 UITableViewHeaderFooterView.ContentView 서브 뷰에 사용자 정의 셀 너비를 자동으로 크기를 조정하고이 코드와 헤더보기에 ContentView에 대한 하위 뷰로 추가 :아이폰 OS

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 landscape/iphone portrait

이 하나가 아이 패드 세로 모드에있는 동안 :

ipad portrait mode

어떻게 만드는

은 아이 패드 가로 모드에서 아이폰 세로 모드에 사용자 정의 셀의 너비는 자동으로 조정됩니까?

답변

0

마침내 내 맞춤형 셀 ContentViewGetViewForHeader에 직접 반환하여 작동하게했습니다.

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