What are some methods to debug Javascript inside of a UIWebView?(有哪些方法可以在 UIWebView 中调试 Javascript?)
问题描述
我试图弄清楚为什么使用 Javascript 的东西在 UIWebView 中不起作用.据我所知,没有办法在 XCode 中为 js 文件设置断点.没问题,我会回到 2004 年并使用警报语句——哦,等等,它们似乎也不能在 UIWebView 中工作!
I'm trying to figure out why something with Javascript isn't working inside of a UIWebView. To my knowledge, there is no way to set a breakpoint inside of XCode for a js file. No problemo, I'll just go back to 2004 and use alert statemen-- oh wait they don't seem to work inside of a UIWebView either!
我唯一能想到的就是将我的 HTML 和 JS 文件导出到我的桌面,然后在 Safari 中进行调试.那行得通!但当然,我在 UIWebView 中遇到的错误不会发生在 Safari 中.
The only thing I could think of is by exporting my HTML And JS files to my desktop and then just doing my debugging inside of Safari. And that works! But of course, the bug I'm fighting with in the UIWebView doesn't occur in Safari.
还有其他方法可以在 UIWebView 内部进行调试,或者我可以使用类似于使用老式警报方法的任何技巧吗?
Are there any other ways for debugging inside of a UIWebView, or any tricks that I can use akin to using the old-school alert method?
推荐答案
如果你使用 iOS >= 6 并且你有山狮 (10.8) 或 Safari >= 6,你可以:
If you're using iOS >= 6 and you have mountain lion (10.8) or Safari >= 6, you can just:
- 在模拟器中打开应用程序(或在 XCode >= 4.5.x 中打开您的设备).
- 打开 Safari(转到
Preferences -> Advanced
并确保Show Develop Menu in Menubar"处于开启状态. - 从(Safari 的)菜单栏选择
Develop ->iPhone 模拟器 ->[您的网页浏览页面]
.
- Open the application in the simulator (or your device in XCode >= 4.5.x).
- Open Safari (go to
Preferences -> Advanced
and make sure "Show Develop Menu in Menubar" is on. - From the Menu-bar (of Safari) select
Develop -> iPhone Simulator -> [your webview page]
.
就是这样!
这篇关于有哪些方法可以在 UIWebView 中调试 Javascript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:有哪些方法可以在 UIWebView 中调试 Javascript?


基础教程推荐
- 使用 Ryzen 处理器同时运行 WSL2 和 Android Studio 2022-01-01
- Android ViewPager:在 ViewPager 中更新屏幕外但缓存的片段 2022-01-01
- LocationClient 与 LocationManager 2022-01-01
- 如何使用 YouTube API V3? 2022-01-01
- Android文本颜色不会改变颜色 2022-01-01
- 固定小数的Android Money Input 2022-01-01
- 如何使 UINavigationBar 背景透明? 2022-01-01
- 在 iOS 上默认是 char 签名还是 unsigned? 2022-01-01
- :hover 状态不会在 iOS 上结束 2022-01-01
- “让"到底是怎么回事?关键字在 Swift 中的作用? 2022-01-01