2012-07-23 40 views
1

我在學習如何使用UISplitViewController,並使用Monotouch提供的「SplitView」示例。我瞭解它是如何工作的,並在主控和細節控制器之間進行通信。Monotouch SplitView示例Cant更改ViewController

因此,它不難改變細節控制器?所以我做了一個很小的修改,它不起作用!我讀過你必須使用SetViewControllers,但Monotouch堆棧中不存在。我哪裏錯了?

這正是相同的代碼從Montouch除了下面的線例如:

public class MainSplitView : UISplitViewController 
{  
    protected Screens.MasterView.MasterTableView masterView; 
    protected Screens.DetailView.DetailViewScreen detailView; 
    protected TestViewController testViewController; // *** Added this line 

    public MainSplitView() : base() 
    { 
     // create our master and detail views 
     masterView = new Screens.MasterView.MasterTableView(); 
     detailView = new Screens.DetailView.DetailViewScreen(); 

     masterView.RowClicked += (object sender, MasterView.MasterTableView.RowClickedEventArgs e) => 
     { 
      detailView.Text = e.Item; 

      testViewController = new TestViewController(); // *** Added this line 
      ViewControllers[0] = masterView;   // *** Added this line 
      ViewControllers[1] = testViewController; // *** Added this line 
      // the UISplitViewController.SetViewControllers does not exist! ??? 
     }; 

     ViewControllers = new UIViewController[] { masterView, detailView }; 

    } 

所有幫助非常感謝!

邁克

回答

1

設置ViewControllers正是你怎麼辦正在做它在其他地方:

ViewControllers = new UIViewController[] { masterView, detailView }; 

只是這樣做:

ViewControllers = new UIViewController[] { masterView, testViewController }; 
+0

工作太棒了!所以顯然無法看到樹木的木材。謝謝。 – hydev 2012-07-24 11:49:48