1. 加入头文件和命名空间
#include "ui/CocosGUI.h"
using namespace cocos2d::experimental::ui;
2. 调用
auto webview = WebView::create();
webview->setContentSize(winSize);
webview->setPosition(winSize/2);
webview->loadURL("http://www.baidu.com");
addChild(webview);
//注: winSize = Director::getInstance()->getWinSize()
3. 关于http访问不安全问题
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file
原因:在iOS9 beta1中,苹果将原http协议改成了https协议,使用 TLS1.2 SSL加密请求数据。
解决方法:在info.plist中加入以下代码
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
网友评论