简体   繁体   English

发送objective-c对象到js?

[英]Sending objective-c object to js?

I'm actually doing an UIWebview with html and js in it. 我实际上在做一个HTML和js的UIWebview。 A friend doing same with Android 一位朋友使用Android进行相同的操作

My problem is that on android, there is a way to just send an Android object to the javascript and use it easily in it 我的问题是,在android上,有一种方法可以将Android对象发送到javascript并在其中轻松使用

But is there a way to do the same in iOS ? 但是有没有办法在iOS中做同样的事情?

I tried to use windowScriptObject but its not available on iphone. 我尝试使用windowScriptObject,但它在iPhone上不可用。 I also tried to send all the datas one per one with 我也尝试过将所有数据一一发送

stringByEvaluatingJavaScriptFromString

but it's kinda ugly :/ 但这有点难看:/

Is there other solution ? 还有其他解决方案吗?

Thanks 谢谢

On iOS the only way is to use stringByEvaluatinfJavaScriptFromString. 在iOS上,唯一的方法是使用stringByEvaluatinfJavaScriptFromString。

But why are you calling the data one by one? 但是,为什么要一一调用数据呢? Package them up into your own data structure, or using Jason is a easy and natural way for passing data to Javascript. 将它们打包成您自己的数据结构,或者使用Jason是将数据传递到Javascript的一种简单自然的方法。

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

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