UIWebView Expose Objective C to JavaScript(UIWebView 将 Objective C 暴露给 JavaScript)
问题描述
在使用 UIWebView 时,如果使用 iPhone SDK,我将如何在 JavaScript 中公开 Objective-C 方法?
How would I expose an Objective-C method within JavaScript when using the iPhone SDK when using the UIWebView?
任何帮助将不胜感激!
推荐答案
最好的方法是通过自定义链接,然后使用 UIWebView 委托方法 -webView:shouldStartLoadWithRequest:navigationType: 捕获请求.当您看到包含您的链接的请求通过时,您就知道您的操作已被触发.
The best way to do this would be through a custom link, and then use the UIWebView delegate method -webView:shouldStartLoadWithRequest:navigationType: to trap requests. When you see a request come through with your link in it, you know your action has been triggered.
这篇关于UIWebView 将 Objective C 暴露给 JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:UIWebView 将 Objective C 暴露给 JavaScript
基础教程推荐
- UIImage 在开始时不适合 UIScrollView 2022-01-01
- Play 商店的设备兼容性问题 2022-01-01
- Android Volley - 如何动画图像加载? 2022-01-01
- SwiftUI-ScrollViewReader的ScrollTo不滚动 2022-01-01
- 如何将图像从一项活动发送到另一项活动? 2022-01-01
- iOS - UINavigationController 添加多个正确的项目? 2022-01-01
- 为什么姜饼模拟器方向卡在应用程序中? 2022-01-01
- navigationItem.backBarButtonItem 不工作?为什么上一个菜单仍然显示为按钮? 2022-01-01
- 如何比较两个 NSDate:哪个是最近的? 2022-01-01
- Xcode UIView.init(frame:) 只能在主线程中使用 2022-01-01
