【发布时间】: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