-
-
Save dalexsoto/d04ff3a1c226757667b776d64d308b1b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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