简体   繁体   English

如何在 Xcode 4.3 上使用 JavaScript?

[英]How to use JavaScript on Xcode 4.3?

I want to use javascript and html5 in xcode 4.3 environment with Iphone SDK.我想在带有 Iphone SDK 的 xcode 4.3 环境中使用 javascript 和 html5。 How can we use and what template i should use?我们如何使用以及我应该使用什么模板? Is there any tutorials for this purpose?有没有为此目的的教程?

well it would work straight away with UIWebview...So create an HTML5 page with Javascript and load it inside UIWebview.好吧,它会直接与 UIWebview 一起工作......所以用 Javascript 创建一个 HTML5 页面并将其加载到 UIWebview 中。

If you have some specific requirement you can use PhoneGAP, Jquery Mobile, Sanchtouch like framework as well.如果您有一些特定要求,您也可以使用 PhoneGAP、Jquery Mobile、Sanchtouch 之类的框架。

Yeah, just create a UIWebView, load the HMTL page you want, you can then call javascript methods on it是的,只要创建一个 UIWebView,加载你想要的 HMTL 页面,然后你就可以在上面调用 javascript 方法

NSString *html = @"<html>Some HTML here</html>"; NSString *html = @"<html>这里是一些 HTML</html>";

[webView loadHTMLString:html baseURL:nil]; [webView loadHTMLString:html baseURL:nil];

[webView stringByEvaluatingJavaScriptFromString:@"someJSToo();"]; [webView stringByEvaluatingJavaScriptFromString:@"someJSToo();"];

You can then just add that UIWebview (in my example assumed to be pre-declared as webView) into your screen:)然后,您可以将该 UIWebview(在我的示例中假定为预先声明为 webView)添加到您的屏幕中:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM