Skip to content

Instantly share code, notes, and snippets.

@dalexsoto
Created June 22, 2017 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dalexsoto/d04ff3a1c226757667b776d64d308b1b to your computer and use it in GitHub Desktop.
Save dalexsoto/d04ff3a1c226757667b776d64d308b1b to your computer and use it in GitHub Desktop.
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