1 #include "ui/CocosGUI.h" 2 3 4 5 using namespace cocos2d::experimental::ui; 6 7 WebView *webView = WebView::create(); 8 9 webView->setPosition(Vec2(visibleSize.width*0.5, visibleSize.height*0.5)); 10 11 webView->setContentSize(visibleSize); 12 13 webView->loadURL("http://www.baidu.com"); 14 15 webView->setScalesPageToFit(true); 16 17 webView->setOnShouldStartLoading([](WebView *sender, const std::string&url){ 18 19 20 21 return true; 22 23 }); 24 25 webView->setOnDidFinishLoading([](WebView *sender, const std::string&url){ 26 27 28 29 }); 30 31 webView->setOnDidFailLoading([](WebView *sender, const std::string&url){ 32 33 34 35 }); 36 37 this->addChild(webView);