Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
248 views
in Technique[技术] by (71.8m points)

c# - How do I get the instance of a (TabView) controller in another one to call a method? (cocoa app in visual studio)

I am coding a cocoa app in visual studio, and building the storyboard through Xcode. I have a TabViewController with 3 tabs, a method implemented to select a given tab, but I can't access it from another ViewController, because I can't access the instance of my TabViewController, only the class.

I'd like to do something like this when the button in the main ViewController is pressed :

Button1_Click(){ MyTabViewController.ChangeTab(1); }

My TabViewController and the other controller are paired with classes, I just can't get back the instance (like you could in Visual Studio for Windows by just writing the name of the controller).

I'm quite new to coding Mac apps, any help appreciated!

Edit : I'm creating a static property in TabViewController to get the instance back in the other class at the moment, works fine, but I think there's a better way around that.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...