在UIWebView中调试Javascript的一些方法是什么? [英] What are some methods to debug Javascript inside of a UIWebView?

查看:139
本文介绍了在UIWebView中调试Javascript的一些方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图弄清楚为什么有些Javascript不能在UIWebView中工作。据我所知,没有办法在XCode中为js文件设置断点。没问题,我会回到2004年,并使用警报状态 - 哦,等待它们似乎不能在UIWebView中使用!



唯一的我可以想到的是通过将我的HTML和JS文件导出到我的桌面,然后在Safari中进行调试。这有效!但是,当然,我在UIWebView中遇到的错误在Safari中不会发生。



是否有任何其他方法可以在UIWebView中进行调试,或者可以使用类似于使用旧式警报方法的技巧?

$ b如果您使用的是iOS> = 6,并且您拥有山狮(10.8)或Safari> = 6,那么您可以:




  1. 在模拟器中打开应用程序(或者您的设备在XCode> 4.5.x中)。
  2. 打开Safari (转到首选项 - >高级并确保菜单栏中的显示菜单已打开。

  3. 从菜单栏(Safari的)选择开发 - > iPhone模拟器 - > [您的webview页面]

就是这样!


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!

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.

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?

解决方案

If you're using iOS >= 6 and you have mountain lion (10.8) or Safari >= 6, you can just:

  1. Open the application in the simulator (or your device in XCode >= 4.5.x).
  2. Open Safari (go to Preferences -> Advanced and make sure "Show Develop Menu in Menubar" is on.
  3. From the Menu-bar (of Safari) select Develop -> iPhone Simulator -> [your webview page].

That's it !

这篇关于在UIWebView中调试Javascript的一些方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆