Skip to content

Instantly share code, notes, and snippets.


dalexsoto/StoryboardHelper.cs Secret

Created Jun 22, 2017
What would you like to do?
using System;
using System.Runtime.InteropServices;
using Foundation;
using UIKit;
using ObjCRuntime;
namespace Workaround {
public static class StoryboardHelper
[DllImport (Constants.ObjectiveCLibrary, EntryPoint = "objc_msgSend")]
public static extern IntPtr IntPtr_objc_msgSend_IntPtr (IntPtr receiver, IntPtr selector, IntPtr arg1);
public static T InstantiateViewController<T> (this UIStoryboard story, string identifier) where T : UIViewController
var nativeId = NSString.CreateNative (identifier);
T vc = Runtime.GetNSObject<T> (IntPtr_objc_msgSend_IntPtr (story.Handle, Selector.GetHandle ("instantiateViewControllerWithIdentifier:"), nativeId));
NSString.ReleaseNative (nativeId);
return vc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment