【问题标题】:xamarin.mac / monomac switch betweeen viewsxamarin.mac / mono mac 在视图之间切换
【发布时间】:2015-03-05 10:21:20
【问题描述】:

我正在关注this tutorial,试图在我的应用程序的不同视图之间进行更改。因为本教程是用 Objective-C 而不是 C# 编写的,所以我很难翻译(我是 C# 新手,没有 Objective-C 经验)。这是我当前不起作用的代码(ourViewController = constFirstView; 行中的错误):

    public const int constFirstViewTag = 0;
    public const int constSecondViewTag = 1;

    public NSViewController ourViewController = new NSViewController();

    partial void changeView (NSObject sender)
    {
        var item = sender as NSToolbarItem;
        int tag = Convert.ToInt32(item.Tag);

        changeViewController(tag);
    }

    public void changeViewController(int tag)
    {
        switch (tag) {
        case constFirstViewTag:
            ourViewController = new GeneralController();
            break;
        case constSecondViewTag:
            ourViewController = new AccountController();
            break;
        }

        ourView.AddSubview (ourViewController.View);
    }

ourView 是我的 customView 控件。 教程中的代码你可以看到here。 提前致谢!

【问题讨论】:

    标签: c# cocoa xamarin monomac xamarin.mac


    【解决方案1】:

    好的,我找到了解决方案。这是有效的 switch 语句(我还更新了上面的代码):

    switch (tag) {
        case constFirstViewTag:
            ourViewController = new GeneralController();
            break;
        case constSecondViewTag:
            ourViewController = new AccountController();
            break;
    }
    

    【讨论】:

      猜你喜欢
      • 2011-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多