Reputation: 85
I'm following this tutorial trying to change between different views on my application. Because the tutorial is written in Objective-C and not C# it's kinda hard for me to translate (I'm a newbie in C# and no Objective-C experience). This is my current code that doesn't work (error in line 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 is my customView control. The code from the tutorial you can see here. Thanks in advance!
Upvotes: 0
Views: 114
Reputation: 85
Ok, I've got the solution. Here's the working switch-statement (I also updated the code above):
switch (tag) {
case constFirstViewTag:
ourViewController = new GeneralController();
break;
case constSecondViewTag:
ourViewController = new AccountController();
break;
}
Upvotes: 0