Forum Xamarin.iOS
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Problem with initialize a viewController

TripleDoubleTripleDouble BGMember ✭✭✭

I have a ModalViewController class. There are some properties and an event

When a make an instance like this

var detailViewController = mStoryBoard.InstantiateViewController("DetailView");
detailViewController.ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext;
mViewController.PresentViewController(detailViewController, true, null);

I can not access these properties and event

When I make an instance like this

var detailViewController = new ModalViewController();

There is not this problem , but the screen of viewController is emty / black - The views / controls are not visible

I need to access the properties and event from ModalViewController class


  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

    Have you tried:

    var detailViewController = mStoryBoard.InstantiateViewController("DetailView") as ModalViewController;


    The above will cast the view controller with storyboard ID of "DetailView" to a ModalViewController... assuming that your DetailView is indeed a ModalViewController. The InstantiateViewController method always returns type UIViewController, so you always have to cast it to the exact subclass of UIViewController that you are using if you want access to the methods and properties of your UIViewController sub-class.

Sign In or Register to comment.