UIWebview 集成在 Cocos2d 游戏中?

发布于 2024-12-05 02:42:12 字数 548 浏览 0 评论 0原文

我正在开发一个小游戏,其中我在 UIWebview 中集成广告。由于 UIKit 对象我在将其添加到 Cocos2d 层时遇到困难。将其添加到一层很简单,但 Webview 需要时间来加载。同时,当我移动到其他类时,UIWebview 加载并添加到特定的 CCLayer 类,以将它们删除在我使用的同一类中,

[webViewH stopLoading];
[webViewF stopLoading];

    webViewF.hidden=YES;
webViewH.hidden=YES;

[webViewH removeFromSuperview];
[webViewF removeFromSuperview];

但是一旦我移动到其他类,我的应用程序就会被杀死,并给出 NSZombieEnabled 错误 - Webview:didCommitLoadForFrame 或有时 Webview:didclearwindowObject。我猜它仍在上一个类中加载,而我已将其从超级视图中删除,因此应用程序被杀死?我可能做错了什么?

i am developing a small game in which i am integrating ads in a UIWebview. Since a UIKit object i am having difficulties in adding it to a Cocos2d layer. its simple enough to add it to one layer but the Webview takes time to load. Meanwhile as i move to some other class the UIWebview loads and gets added to that particular CCLayer class,to remove them in the very same class i use

[webViewH stopLoading];
[webViewF stopLoading];

    webViewF.hidden=YES;
webViewH.hidden=YES;

[webViewH removeFromSuperview];
[webViewF removeFromSuperview];

but my app gets killed as soon as i move to the other class giving error with NSZombieEnabled -- Webview:didCommitLoadForFrame or sometimes Webview:didclearwindowObject. i guess its still loading in the previous class while i have removed it from superview so app gets killed?? what am i possibly doing wrong??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

余生共白头 2024-12-12 02:42:12

我最近使用 cocos2d 论坛上发布的类将 UIWebView 添加到我的 cocos2d 游戏中。它称为 CCUIViewWrapper,顾名思义,它是一个包装任何 UIView 控件的 CCNode 对象。相当整洁。

在这里查看更多信息:

http://www.cocos2d-iphone.org/forum/tags/ ccuiviewwrapper

I recently added a UIWebView to my cocos2d game using a class posted on the cocos2d forum. It's called CCUIViewWrapper and as its name suggests is a CCNode object that wraps any UIView control. Pretty neat.

See more at here:

http://www.cocos2d-iphone.org/forum/tags/ccuiviewwrapper

怀中猫帐中妖 2024-12-12 02:42:12

你不能将 UIView 添加到任何 Cocos 对象,因为它们不是 UIView。将 UIWebView 添加到 openGLView,这会将视图置于游戏之上,这就是您想要的:

[[CCDirector sharedDirector] openGLView] addSubView:webview];

You can't add UIViews to any Cocos object since they aren't UIViews. Add the UIWebView to the openGLView, which will put the view on top of your game, which is what you wanted:

[[CCDirector sharedDirector] openGLView] addSubView:webview];

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文