public ContentView(UIColor fillColor) { BackgroundColor = fillColor; webView = new UIWebView(UIScreen.MainScreen.Bounds); var context = (JSContext)webView.ValueForKeyPath((NSString)"documentView.webView.mainFrame.javaScriptContext"); context.ExceptionHandler = (JSContext context2, JSValue exception) => { Console.WriteLine("JS exception: {0}", exception); }; var obj = new MSJSExporter(); context[(NSString)"myCSharpObject"] = JSValue.From(obj, context); webView.LoadRequest(NSUrlRequest.FromUrl(new NSUrl("MyHtmlFile.html", false))); this.AddSubview(webView); }
public void JSExportTest() { var webView = new UIWebView(); var context = (JSContext)webView.ValueForKeyPath((NSString)"documentView.webView.mainFrame.javaScriptContext"); context.ExceptionHandler = (JSContext context2, JSValue exception) => { Console.WriteLine("JS exception: {0}", exception); }; var obj = new MSJSExporter(); context[(NSString)"obj"] = JSValue.From(obj, context); var val = context.EvaluateScript("obj.myFunc ();"); }