2014-10-03 44 views
0

我試圖用這個:如何將MonoTouch.Dialog元素嵌入到ViewController中?

Adding a Monotouch.Dialog to a standard view

我能看到的視圖元素當我這樣做......但是點擊單選要素之一什麼也不做(出例如複選框) 。不知道我做錯了什麼。

這裏是我使用裏面viewDidLoad中()

var rootElement = new RootElement("Question Text", new RadioGroup("answer", 0)) 
    { 
     new Section() 
     { 
      new RadioElement("Answer A", "answer"), 
      new RadioElement("Answer B", "answer"), 
      new RadioElement("Answer C", "answer"), 
      new RadioElement("Answer D", "answer") 
     } 
    }; 

    _questionDialogViewController = new DialogViewController(rootElement); 
    _questionDialogViewController.View.BackgroundColor = UIColor.Clear.FromHexString(AppDelegate.EventModel.MainBackgroundColor); 
    _questionDialogViewController.View.Frame = new RectangleF(0, 250, 864, 500); 
    View.AddSubview(_questionDialogViewController.View); 

回答

0

我發現,這是與過去不斷擴大的視圖 - 控制的邊緣對話框控制問題的代碼。

解決的辦法是添加一箇中間的UIView作爲容器來強制DialogController保持在正確的範圍內。

正確的代碼結束了:

var rootElement = new RootElement("Question Text", new RadioGroup("answer", 0)) 
{ 
    new Section() 
    { 
     new RadioElement("Answer A", "answer"), 
     new RadioElement("Answer B", "answer"), 
     new RadioElement("Answer C", "answer"), 
     new RadioElement("Answer D", "answer") 
    } 
}; 

_questionDialogViewController = new DialogViewController(rootElement); 
_questionDialogViewController.View.BackgroundColor = UIColor.Clear.FromHexString(AppDelegate.EventModel.MainBackgroundColor); 
_questionDialogViewController.View.Frame = new RectangleF(0, 0, 964, 500); 

var answerContainer = new UIView(new RectangleF(30, 150, 964, 500)); 
answerContainer.AddSubview(_questionDialogViewController.View); 

View.AddSubview(answerContainer); 
相關問題