2012-03-30 5 views
2

iPad 화면에서 MonoTouch.Dialog를 사용하고 있습니다.MonoTouch.Dialog 내에서 셀 너비를 설정하는 방법

MonoTouch.Dialog 테이블을 플로팅 한 전체 화면 배경을 만들었습니다.

전체 화면 배경을 그대로두고 MonoTouch.Dialog 테이블 (또는 모든 셀)의 너비를 변경하고 싶습니다. 어떻게해야합니까?

답변

0

DialogViewController가 UITableViewController 및 UITableView와 유사하기 때문에이 기능을 직접 수행 할 수 없습니다. UITableView는 포함 된 공간을 채울 특성이 있습니다. 당신이 원하는 너비에 대한 "컨테이너"UIView를 만들고 UIViewController에 하위 뷰로 추가해야 할 곳을 둘러 보도록하는 영리한 트릭이 있습니다. 이제 DialogViewController를 만들고 View를 해당 컨테이너의 하위보기로 추가하십시오. 대화 상자는 부모보기가 아닌 컨테이너 크기로 확장됩니다.

public class MyController : UIViewController 
{ 
    UIView container; 
    DialogViewController dvc; 

    public override void ViewDidLoad() 
    { 
     base.ViewDidLoad(); 

     container = new UIView(); 
     dvc = new DialogViewController(UITableViewStyle.Grouped, null, true); 
     dvc.Root = new Root("Title") { 
      new Section() { 
       new StringElement("Hello") 
      } 
     }; 

     View.AddSubview(container); 
    } 

    public override void ViewDidLayoutSubviews() 
    { 
     base.ViewDidLayoutSubviews(); 

     // Whatever width you want 
     float newWidth = View.Bounds.Width/2; 
     container.Frame = new RectangleF(0, 0, newWidth, View.Bounds.Height); 

     // This is a workaround so that the TableView fills the container view 
     // after it is sized. 
     container.AddSubView(dvc.View); 
    } 
} 
:이 같은 뭔가

결국합니다

관련 문제