diff options
Diffstat (limited to 'Xamarin.Forms.Platform.iOS/PageExtensions.cs')
-rw-r--r-- | Xamarin.Forms.Platform.iOS/PageExtensions.cs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.iOS/PageExtensions.cs b/Xamarin.Forms.Platform.iOS/PageExtensions.cs new file mode 100644 index 00000000..07da048a --- /dev/null +++ b/Xamarin.Forms.Platform.iOS/PageExtensions.cs @@ -0,0 +1,33 @@ +using System; +#if __UNIFIED__ +using UIKit; + +#else +using MonoTouch.UIKit; +#endif + +namespace Xamarin.Forms +{ + public static class PageExtensions + { + public static UIViewController CreateViewController(this Page view) + { + if (!Forms.IsInitialized) + throw new InvalidOperationException("call Forms.Init() before this"); + + if (!(view.RealParent is Application)) + { + Application app = new DefaultApplication(); + app.MainPage = view; + } + + var result = new Platform.iOS.Platform(); + result.SetPage(view); + return result.ViewController; + } + + class DefaultApplication : Application + { + } + } +}
\ No newline at end of file |