UIWebview 集成在 Cocos2d 游戏中?
我正在开发一个小游戏,其中我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我最近使用 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
你不能将 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];