简体   繁体   中英

How do I open a new storyboard from custom controller class in Xamarin.ios native app?

We are using custom controller class to bind UITableView in xamarin.ios, so we need to open a new storyboard on a image tap gesture event. How to open new storyboard/controller? When we write a code in tap gesture event its showing compile Time error, please see code below,

UIStoryboard st = this.Storyboard;
clsNewStoryboard CRVC = clsNewStoryboard)st.InstantiateViewController(“NewStoryboard”); this.PresentViewController(CRVC, true, null);

So we have create a method in our main viewController class and write same code Ie mention above, Now its throw runtime error “Object reference not set to an instance to object”.

How to solve this issue.. please guide/help..

Simple way is you can create StoryBoard reference from present storyboard to new StoryBoard and call PerformSegue on tap gesture event.

                OR

Programatically you can do it by using the code below

UIStoryboard newStoryBoard = UIStoryboard.FromName("NewStoryBoardName", null);
UIViewController viewControllerYouWantToLoad = (ViewControllerYouWantToLoad)newStoryBoard.InstantiateViewController(ViewControllerYouWantToLoadIdentifier);
PresentViewController(viewControllerYouWantToLoad, true, null);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM