Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# PresentViewController to a viewcontroller in storyboard

I am creating my first Xamarin-application (C#) in iOS and I am having trouble with navigating in storyboard. All of my tabbar-,navigation- and viewcontrollers are in the storyboard. In almost every viewcontroller, I added a menu (Facebook- and YouTube-style) which slides from the side. From there it has to be possible to return to the first viewcontroller (home) in storyboard. Because the menu is active in almost every controller of my application, I don't use segues (It would be a mess in my storyboard).

So I would want to use PresentViewController(), but when I do this, the page turnes black and doesn't show anything.

homeViewController home = new homeViewController();
PresentViewController(home, true, null);

Does it turn black because PresentViewController expects a XIB-file from the homeViewController? I want the user to stay in the storyboard, so he can continue by segueing through my application.

Does someone has an idea?

Thanks in advance.

like image 499
MobileExperience Avatar asked Apr 09 '13 09:04

MobileExperience


Video Answer


1 Answers

Did you create the empty constructor yourself? If so, then its not loading the information from the storyboard, which is why it's black.

To create the controller call this:

var controller = Storyboard.InstantiateViewController("HomeViewController") as UIViewController;

You will also have to open the controller in XCode and set its "Storyboard ID" to "HomeViewController". This is the second tab from the left (I think) in the details pane. The same tab where you change the class.

like image 112
jonathanpeppers Avatar answered Oct 19 '22 18:10

jonathanpeppers