简体   繁体   English

从obj-c openfeint调用js

[英]calling js from obj-c openfeint

I can call js from obj-c from the phonegap plugin classes and the main app delegate class as follows: [webView stringByEvaluatingJavaScriptFromString:@"alert('Hello');"]; 我可以从phone-gap插件类和主应用程序委托类的obj-c中调用js,如下所示:[webView stringByEvaluatingJavaScriptFromString:@“ alert('Hello');”];

You can do this because the webView object can be handled by the phonegap plugin classes and the phonegap main app delegate. 您可以执行此操作,因为webView对象可以由phonegap插件类和phonegap主应用程序委托处理。

However I am integrating Openfeint and it has many of its own classes. 但是,我正在集成Openfeint,它具有许多自己的类。 When I try the above code in an Openfeint delegate class it doesn't work because the Openfeint delegate classes can't get a handle on the webView object. 当我在Openfeint委托类中尝试上述代码时,由于Openfeint委托类无法获取webView对象的句柄,因此它不起作用。

Can anyone tell me how to do this? 谁能告诉我该怎么做? I've tried messing with the class interfaces and importing .h files in various places but nothing seems to be working. 我尝试弄乱类接口并在各个地方导入.h文件,但似乎没有任何效果。 Obviously webView is sitting there somewhere. 显然,webView坐在那里。

I am hacker of obj-c as opposed to someone who really understands it. 我是obj-c的黑客,而不是真正了解它的人。

I have gotten achievements and leaderboards working for my app. 我的应用取得了成就和排行榜。 This is relatively straight forward. 这是相对简单的。 USers can also create and send new challenges. 美国人也可以创造并提出新的挑战。

But I cannot get users who receive these challenges to play them because of the problem above (at least that's my theory). 但是由于上述问题(至少是我的理论),我无法让接受这些挑战的用户玩这些游戏。

I'll share all my Openfeint know how once I get this problem sorted and release my app. 我将分享我所有的Openfeint知识,一旦我解决了这个问题并发布了我的应用程序。

Cheers 干杯

Nigel 奈杰尔

I think you can safely reduced your problem to a simple one. 我认为您可以安全地将问题简化为一个简单的问题。 Passing the webview object to Openfeint-classes, or may be a single super class. 将webview对象传递给Openfeint类,或者可以是单个超类。 (I have never used openfeint and if this isn't the problem, then please don't read further) (我从未使用过openfeint,如果这不是问题,请不要继续阅读)

These are two different questions on stackoverflow related to sharing/passing a variable among classes. 这是关于堆栈溢出的两个不同的问题,这些问题与在类之间共享/传递变量有关。 There may be more, and you can search for what suits your requirements on these lines. 可能还有更多,您可以在这些行中搜索适合您要求的内容。

Passing variables through classes in Objective-C 通过Objective-C中的类传递变量

How do I pass variables between view controllers? 如何在视图控制器之间传递变量?

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

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