How to call Objective-C from Javascript?

前端 未结 8 1683
误落风尘
误落风尘 2020-11-22 17:38

I have a WebView, and I want to call a view in Objective-C from JavaScript. Does someone know how I can do this?


I have this code in my ViewController:

8条回答
  •  一向
    一向 (楼主)
    2020-11-22 18:01

    Obliviux,

    Your code seems to be perfect.

    The reason for the problem is that you must have missed to map the delegate.

    Either

    1. Connect the delegate of the webView to the file owner in the .xib file

    or

    1. Use webView.delegate = self;

    in your viewDidLoad.

    Thanks

提交回复
热议问题