0

Check this code

Storyboard ---UIViewController1 ---UIViewController2

---UIViewController1 contain a button on press call ---UIViewController2 and in ---UIViewController2 i need to open EasyJSwebviewSample code

Reference code - https://github.com/dukeland/EasyJSWebViewSample/blob/master/EasyJSWebViewSample/MyJSInterface.m

9to5ios
  • 5,319
  • 2
  • 37
  • 65

1 Answers1

0

You need to place a UIWebView inside UIViewController2 then use below code. then add below code in UIViewController2 to run the EasyJSWebView code.

MyJSInterface* interface = [MyJSInterface new];
[self.myWebView addJavascriptInterfaces:interface WithName:@"MyJSTest"];
[interface release];

MyJSInterface is derived NSObject class its not a VC.

Note: WKWebView provides native bridge between javascript and objective c see this SO URL Call JavaScript function from native code in WKWebView

Community
  • 1
  • 1
Pandey_Laxman
  • 3,889
  • 2
  • 21
  • 39