Monotouch SplitView示例无法更改ViewController

时间:2012-07-23 22:05:54

标签: xamarin.ios

我正在尝试学习如何使用UISplitViewController,我正在使用Monotouch提供的“SplitView”示例。我理解它是如何工作的,并在Master和Detail控制器之间进行通信。

因此改变细节控制器不难吗?所以我做了一个非常小的修正案,它不起作用!我已经读过你必须使用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 个答案:

答案 0 :(得分:1)

设置ViewControllers你到底在另一个地方做了什么:

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

这样做:

ViewControllers = new UIViewController[] { masterView, testViewController };
相关问题