基本控件使用(WebView)

項目中,難免會遇到要做一個內嵌的網頁,現Lua中,綁定好了WebView,下邊看一下具體的用法:

local webView = ccexp.WebView:create()

webView:setContentSize(cc.size(1280, 600))

webView:setScalesPageToFit(true)

webView:setPosition(cc.p(640, 300))

webView:loadURL(“http://www.baidu.com”)

layer:addChild(webView)

webView:setOnShouldStartLoading(function(sender, url)

print("onWebViewShouldStartLoading,url is ", url)

     return true

end)

webView:setOnDidFinishLoading(function(sender, url)

print("onWebViewDidFinishLoading,url is ", url)

end)

webView:setOnDidFailLoading(function(sender, url)

print("onWebViewDidFinishLoading,url is ", url)

end)

webView:reload()                               --重新加載,再第一訪問的時候可以不填寫


————————————————
版權聲明:本文爲CSDN博主「xiaosong15311」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/u011874528/article/details/52045723

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章